2004-11-23 [colin] 0.9.12cvs166.1
authorColin Leroy <colin@colino.net>
Tue, 23 Nov 2004 15:57:07 +0000 (15:57 +0000)
committerColin Leroy <colin@colino.net>
Tue, 23 Nov 2004 15:57:07 +0000 (15:57 +0000)
* src/Makefile.am
* src/codeconv.c
* src/compose.c
* src/folderview.c
* src/main.c
* src/partial_download.c
* src/partial_download.h
* src/prefs_account.c
* src/prefs_account.h
* src/privacy.c
* src/privacy.h
* src/procmime.c
* src/common/Makefile.am
* src/common/base64.h
* src/common/partial_download.c
* src/common/partial_download.h
* src/gtk/prefswindow.c
* src/gtk/prefswindow.h
* src/plugins/pgpmime/pgpmime.c
* src/plugins/pgpmime/prefs_gpg.c
* src/plugins/pgpmime/prefs_gpg.h
* src/plugins/pgpmime/sgpgme.c
* src/plugins/pgpmime/sgpgme.h
Sync with HEAD

24 files changed:
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/Makefile.am
src/codeconv.c
src/common/Makefile.am
src/common/base64.h
src/common/partial_download.c [deleted file]
src/common/partial_download.h [deleted file]
src/compose.c
src/folderview.c
src/gtk/prefswindow.c
src/gtk/prefswindow.h
src/main.c
src/plugins/pgpmime/pgpmime.c
src/plugins/pgpmime/prefs_gpg.c
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
src/procmime.c

index 948429d335da5139a8cc9a80e145caf5e3d69770..869c3fa2224bc6ab70df6029ec70d76e6fe0cafc 100644 (file)
@@ -1,3 +1,30 @@
+2004-11-23 [colin]     0.9.12cvs166.1
+
+       * src/Makefile.am
+       * src/codeconv.c
+       * src/compose.c
+       * src/folderview.c
+       * src/main.c
+       * src/partial_download.c
+       * src/partial_download.h
+       * src/prefs_account.c
+       * src/prefs_account.h
+       * src/privacy.c
+       * src/privacy.h
+       * src/procmime.c
+       * src/common/Makefile.am
+       * src/common/base64.h
+       * src/common/partial_download.c
+       * src/common/partial_download.h
+       * src/gtk/prefswindow.c
+       * src/gtk/prefswindow.h
+       * src/plugins/pgpmime/pgpmime.c
+       * src/plugins/pgpmime/prefs_gpg.c
+       * src/plugins/pgpmime/prefs_gpg.h
+       * src/plugins/pgpmime/sgpgme.c
+       * src/plugins/pgpmime/sgpgme.h
+               Sync with HEAD
+
 2004-11-23 [colin]     0.9.12cvs163.1
 
        * src/main.c
index 40a7ee6f8b84c5bcb2c0e841dd90fb90e15cc40e..5c2a8549b1953ddc097ef535b767fdbeed23551b 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.73 -r 1.382.2.74 src/compose.c; cvs diff -u -r 1.16.2.9 -r 1.16.2.10 src/msgcache.c; ) > 0.9.12cvs158.9.patchset
 ( cvs diff -u -r 1.204.2.24 -r 1.204.2.25 src/prefs_common.c; cvs diff -u -r 1.3.2.13 -r 1.3.2.14 src/prefs_themes.c; cvs diff -u -r 1.150.2.17 -r 1.150.2.18 src/procmsg.c; ) > 0.9.12cvs162.1.patchset
 ( cvs diff -u -r 1.115.2.23 -r 1.115.2.24 src/main.c; ) > 0.9.12cvs163.1.patchset
+( cvs diff -u -r 1.155.2.13 -r 1.155.2.14 src/Makefile.am; cvs diff -u -r 1.65.2.19 -r 1.65.2.20 src/codeconv.c; cvs diff -u -r 1.382.2.74 -r 1.382.2.75 src/compose.c; cvs diff -u -r 1.207.2.21 -r 1.207.2.22 src/folderview.c; cvs diff -u -r 1.115.2.24 -r 1.115.2.25 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.105.2.13 -r 1.105.2.14 src/prefs_account.c; cvs diff -u -r 1.49.2.8 -r 1.49.2.9 src/prefs_account.h; cvs diff -u -r 1.10.2.3 -r 1.10.2.4 src/privacy.c; cvs diff -u -r 1.10.2.2 -r 1.10.2.3 src/privacy.h; cvs diff -u -r 1.49.2.22 -r 1.49.2.23 src/procmime.c; cvs diff -u -r 1.24.2.4 -r 1.24.2.5 src/common/Makefile.am; cvs diff -u -r 1.1 -r 1.2 src/common/base64.h; cvs diff -u -r -1.1.2.5 -r -1.1.2.6 src/common/partial_download.c; cvs diff -u -r -1.1.2.2 -r -1.1.2.3 src/common/partial_download.h; cvs diff -u -r 1.12.2.7 -r 1.12.2.8 src/gtk/prefswindow.c; cvs diff -u -r 1.7.2.1 -r 1.7.2.2 src/gtk/prefswindow.h; cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/plugins/pgpmime/pgpmime.c; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/plugins/pgpmime/prefs_gpg.c; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/plugins/pgpmime/prefs_gpg.h; cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/pgpmime/sgpgme.c; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/plugins/pgpmime/sgpgme.h; ) > 0.9.12cvs166.1.patchset
index 76e8dcc2e759d512de419932109f279fd799dc83..382ad67e2c98fab4aea46d261f4cf882dc2a78b8 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=163
+EXTRA_VERSION=166
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=.1
 
index 114b9a387a677df6e35018e1ee57d0c6b1a925a1..48823a4a49db2ac5b03862af7667d6cbe36341d9 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 \
@@ -206,6 +207,7 @@ sylpheedinclude_HEADERS = \
        news_gtk.h \
        noticeview.h \
        pine.h \
+       partial_download.h \
        pop.h \
        prefs_account.h \
        prefs_actions.h \
index 8df7f211350d1ed7297012a5550e149249bac3c7..c8a960dbf428892c25f46df8c49dfe3609f7a346 100644 (file)
@@ -1495,8 +1495,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 759273cddddc9bc7970cecb941687b78b4023196..b8c93f475fd12d3659a515283f5ae50f27aa9d7f 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 4aa557583430a96ae83dcae1b667fc6a38c73054..5152e0a1bc14840e9ec22bc69d537490eb4edc74 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
diff --git a/src/common/partial_download.c b/src/common/partial_download.c
deleted file mode 100644 (file)
index 65f6e3e..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
- * This file (C) 2004 Colin Leroy
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * 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.
- */
-
-/* Partial download:
- * A mail which has been completely downloaded will have no special headers,
- * and its entry in the uidl file will end by 0 (POP3_TOTALLY_RECEIVED);
- *
- * A mail which has been partially downloaded will have some special headers,
- * and its entry in the uidl file will first be 1 (POP3_PARTIALLY_RECEIVED);
- * the special headers will be including "SC-Marked-For-Download" which can 
- * have three values:
- * 0 (POP3_PARTIAL_DLOAD_UNKN) meaning that the user has not yet chosen to
- *  download the mail or let it be deleted - this header is absent until the
- *  user first chooses an action
- * 1 (POP3_PARTIAL_DLOAD_DLOAD) meaning that the user wants to finish 
- *  downloading the mail
- * 2 (POP3_PARTIAL_DLOAD_DELE) meaning that the user does not want to finish
- *  downloading the mail
- * When updating this header to POP3_PARTIAL_DLOAD_DLOAD, the uidl line of
- * this mail will end with the mail's physical path, which Sylpheed will remove
- * after having downloaded the complete mail. msg->partial_recv will equal
- * 2 (POP3_MUST_COMPLETE_RECV).
- * When updating this header to POP3_PARTIAL_DLOAD_DELE, the uidl line of
- * this mail will be 0 (POP3_TOTALLY_RECEIVED), which will let Sylpheed delete
- * this mail from the server as soon as the leave_time preference specifies.
- */
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <glib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <time.h>
-#include <errno.h>
-
-#include "intl.h"
-#include "partial_download.h"
-#include "utils.h"
-#include "../pop.h"
-#include "../folder.h"
-#include "../procheader.h"
-#include "../msgcache.h"
-
-int partial_msg_in_uidl_list(MsgInfo *msginfo)
-{
-       gchar *path;
-       FILE *fp;
-       gchar buf[POPBUFSIZE];
-       gchar uidl[POPBUFSIZE];
-       time_t recv_time;
-       time_t now;
-       gint partial_recv;
-       
-       if (!msginfo->account_server
-       ||  !msginfo->account_login
-       ||  !msginfo->partial_recv)
-               return FALSE;
-       
-       path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
-                          "uidl", G_DIR_SEPARATOR_S, msginfo->account_server,
-                          "-", msginfo->account_login, NULL);
-       if ((fp = fopen(path, "rb")) == NULL) {
-               if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
-               g_free(path);
-               path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
-                                  "uidl-", msginfo->account_server,
-                                  "-", msginfo->account_login, NULL);
-               if ((fp = fopen(path, "rb")) == NULL) {
-                       if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
-                       g_free(path);
-                       return FALSE;
-               }
-       }
-       g_free(path);
-
-       now = time(NULL);
-
-       while (fgets(buf, sizeof(buf), fp) != NULL) {
-               gchar tmp[POPBUFSIZE];
-               strretchomp(buf);
-               recv_time = RECV_TIME_NONE;
-               partial_recv = POP3_TOTALLY_RECEIVED;
-               
-               if (sscanf(buf, "%s\t%ld\t%s", uidl, &recv_time, tmp) < 2) {
-                       if (sscanf(buf, "%s", uidl) != 1)
-                               continue;
-                       else {
-                               recv_time = now;
-                       }
-               }
-               if (!strcmp(uidl, msginfo->partial_recv)) {
-                       fclose(fp);
-                       return TRUE;
-               }
-       }
-
-       fclose(fp);     
-       return FALSE;
-}
-
-static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
-{
-       gchar *path;
-       gchar *pathnew;
-       FILE *fp;
-       FILE *fpnew;
-       gchar buf[POPBUFSIZE];
-       gchar uidl[POPBUFSIZE];
-       time_t recv_time;
-       time_t now;
-       int len;
-       int start = TRUE;
-       gchar partial_recv[POPBUFSIZE];
-       int err = -1;
-
-       gchar *filename;
-       MsgInfo *tinfo;
-       filename = procmsg_get_message_file_path(msginfo);
-       if (!filename) {
-               g_warning("can't get message file path.\n");
-               return err;
-       }
-       tinfo = procheader_parse_file(filename, msginfo->flags, TRUE, TRUE);
-
-       if (!tinfo->account_server
-       ||  !tinfo->account_login
-       ||  !tinfo->partial_recv) {
-               goto bail;
-       }
-       path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
-                          "uidl", G_DIR_SEPARATOR_S, tinfo->account_server,
-                          "-", tinfo->account_login, NULL);
-       if ((fp = fopen(path, "rb")) == NULL) {
-               perror("fopen1");
-               if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
-               g_free(path);
-               path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
-                                  "uidl-", tinfo->account_server,
-                                  "-", tinfo->account_login, NULL);
-               if ((fp = fopen(path, "rb")) == NULL) {
-                       if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
-                       g_free(path);
-               }
-               goto bail;
-       }
-
-       pathnew = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
-                          "uidl", G_DIR_SEPARATOR_S, tinfo->account_server,
-                          "-", tinfo->account_login, ".new", NULL);
-       if ((fpnew = fopen(pathnew, "wb")) == NULL) {
-               perror("fopen2");
-               fclose(fp);
-               g_free(pathnew);
-               goto bail;
-       }
-       
-       now = time(NULL);
-
-       while (fgets(buf, sizeof(buf), fp) != NULL) {
-               strretchomp(buf);
-               recv_time = RECV_TIME_NONE;
-               sprintf(partial_recv,"0");
-               
-               if (sscanf(buf, "%s\t%ld\t%s", 
-                          uidl, &recv_time, partial_recv) < 2) {
-                       if (sscanf(buf, "%s", uidl) != 1)
-                               continue;
-                       else {
-                               recv_time = now;
-                       }
-               }
-               if (strcmp(tinfo->partial_recv, uidl)) {
-                       fprintf(fpnew, "%s\t%ld\t%s\n", 
-                               uidl, recv_time, partial_recv);
-               } else {
-                       gchar *stat = NULL;
-                       if (download == POP3_PARTIAL_DLOAD_DLOAD) {
-                               gchar *folder_id = folder_item_get_identifier(
-                                                       msginfo->folder);
-                               stat = g_strdup_printf("%s:%d",
-                                       folder_id, msginfo->msgnum);
-                               g_free(folder_id);
-                       }
-                       else if (download == POP3_PARTIAL_DLOAD_UNKN)
-                               stat = g_strdup("1");
-                       else if (download == POP3_PARTIAL_DLOAD_DELE)
-                               stat = g_strdup("0");
-                       
-                       fprintf(fpnew, "%s\t%ld\t%s\n", 
-                               uidl, recv_time, stat);
-                       g_free(stat);
-               }
-       }
-       fclose(fpnew);
-       fclose(fp);
-
-       move_file(pathnew, path, TRUE);
-
-       g_free(path);
-       g_free(pathnew);
-       
-       if ((fp = fopen(filename,"rb")) == NULL) {
-               perror("fopen3");
-               goto bail;
-       }
-       pathnew = g_strdup_printf("%s.new", filename);
-       if ((fpnew = fopen(pathnew, "wb")) == NULL) {
-               perror("fopen4");
-               fclose(fp);
-               g_free(pathnew);
-               goto bail;
-       }
-       
-       while ((len = fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
-               buf[len]='\0';
-               if (start) {
-                       start = FALSE;
-                       fprintf(fpnew, "SC-Marked-For-Download: %d\n", 
-                                       download);
-                       
-                       if(strlen(buf) > strlen("SC-Marked-For-Download: x\n")
-                       && !strncmp(buf, "SC-Marked-For-Download:", 
-                                   strlen("SC-Marked-For-Download:"))) {
-                               fprintf(fpnew, "%s", 
-                                buf+strlen("SC-Marked-For-Download: x\n"));
-                               continue;
-                       }
-               }
-               fprintf(fpnew, "%s", buf);
-       }
-       fclose(fpnew);
-       fclose(fp);
-       unlink(filename);
-       rename(pathnew, filename);
-       g_free(pathnew);
-       msginfo->planned_download = download;
-       msgcache_update_msg(msginfo->folder->cache, msginfo);
-
-       err = 0;
-bail:
-       g_free(filename);
-       procmsg_msginfo_free(tinfo);
-       
-       return err;
-}
-int partial_mark_for_delete(MsgInfo *msginfo)
-{
-       return partial_uidl_mark_mail(msginfo, POP3_PARTIAL_DLOAD_DELE);
-}
-
-int partial_mark_for_download(MsgInfo *msginfo)
-{
-       return partial_uidl_mark_mail(msginfo, POP3_PARTIAL_DLOAD_DLOAD);
-}
-
-int partial_unmark(MsgInfo *msginfo)
-{
-       return partial_uidl_mark_mail(msginfo, POP3_PARTIAL_DLOAD_UNKN);
-}
-
-void partial_delete_old(const gchar *file) 
-{
-       gchar *id = g_strdup(file);
-       gchar *snum = strrchr(file, ':');
-       int num = 0;
-       FolderItem *item = NULL;
-
-       debug_print("too big message updated,should remove %s\n", file);
-
-       if (snum) {
-               snum++;
-       } else {
-               g_free(id);
-               return; /* not a real problem */
-       }
-
-       num = atoi(snum);
-
-       if (strrchr(id, ':'))
-               *(strrchr(id, ':'))='\0';
-
-       item = folder_find_item_from_identifier(id);
-       if (item) {
-               debug_print("removing %d in %s\n", num, id);
-               folder_item_remove_msg(item, num);
-       } 
-       g_free(id);
-}
-
-gchar *partial_get_filename(const gchar *server, const gchar *login,
-                                  const gchar *muidl)
-{
-       gchar *path;
-       gchar *result = NULL;
-       FILE *fp;
-       gchar buf[POPBUFSIZE];
-       gchar uidl[POPBUFSIZE];
-       time_t recv_time;
-       time_t now;
-       gint partial_recv;
-       
-       path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
-                          "uidl", G_DIR_SEPARATOR_S, 
-                          server, "-", login, NULL);
-       if ((fp = fopen(path, "rb")) == NULL) {
-               if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
-               g_free(path);
-               path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
-                                  "uidl-", server,
-                                  "-", login, NULL);
-               if ((fp = fopen(path, "rb")) == NULL) {
-                       if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
-                       g_free(path);
-                       return result;
-               }
-       }
-       g_free(path);
-
-       now = time(NULL);
-
-       while (fgets(buf, sizeof(buf), fp) != NULL) {
-               gchar tmp[POPBUFSIZE];
-               strretchomp(buf);
-               recv_time = RECV_TIME_NONE;
-               partial_recv = POP3_TOTALLY_RECEIVED;
-               
-               if (sscanf(buf, "%s\t%ld\t%s", uidl, &recv_time, tmp) < 2) {
-                       if (sscanf(buf, "%s", uidl) != 1)
-                               continue;
-                       else {
-                               recv_time = now;
-                       }
-               }
-               if (!strcmp(muidl, uidl)) {
-                       result = g_strdup(tmp);
-                       break;
-               }
-       }
-
-       fclose(fp);
-       
-       return result;
-}
-
diff --git a/src/common/partial_download.h b/src/common/partial_download.h
deleted file mode 100644 (file)
index 2ac6b77..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
- * This file (C) 2004 Colin Leroy
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * 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.
- */
-#ifndef __PARTIAL_DOWNLOAD_H__
-#define __PARTIAL_DOWNLOAD_H__
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <glib.h>
-#include <time.h>
-
-#include "../procmsg.h"
-
-typedef enum {
-       POP3_PARTIAL_DLOAD_UNKN = 0,
-       POP3_PARTIAL_DLOAD_DLOAD= 1,
-       POP3_PARTIAL_DLOAD_DELE = 2
-} PartialDownloadAction;
-
-typedef enum {
-       POP3_TOTALLY_RECEIVED   = 0,
-       POP3_PARTIALLY_RECEIVED = 1,
-       POP3_MUST_COMPLETE_RECV = 2
-} PartialDownloadStatus;
-
-gint   partial_msg_in_uidl_list        (MsgInfo        *msginfo);
-int    partial_mark_for_download(MsgInfo       *msginfo);
-int    partial_mark_for_delete (MsgInfo        *msginfo);
-int    partial_unmark          (MsgInfo        *msginfo);
-gchar *partial_get_filename    (const gchar    *server,
-                                const gchar    *login, 
-                                const gchar    *muidl);
-void   partial_delete_old      (const gchar    *file);
-
-#endif /* __PARTIAL_DOWNLOAD_H__ */
index c00aef4e90045ac0c148dbaa058063235d47633f..9367dc470c9f93ca54440e8f9e1132bb4191e5ae 100644 (file)
@@ -3640,7 +3640,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 29f560d290b290fd0041c27d9e437547200a674f..b620b41b2ad2f0718ba6a55c547df80525540adc 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 6074f48f993ef6c8ab9578ee2dfd79c7684df80c..5945bde8deb5ebf8b456e047cf2d17dbaac345bd 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_TOPLEVEL);
@@ -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_AUTOMATIC);
        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 */
@@ -317,6 +327,8 @@ void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
                                &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);
 
        g_signal_connect(G_OBJECT(prefswindow->ok_btn), "released", 
@@ -328,5 +340,11 @@ void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
        g_signal_connect(G_OBJECT(prefswindow->window), "delete_event", 
                         G_CALLBACK(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);
+}
+
index 016f4fba4e19eb220d27692ed8714314684ec269..786ae9c8d12ba54dfa566bddc5b590e53b78e21f 100644 (file)
@@ -41,6 +41,11 @@ 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 1c9f36e3ca4022cf186136a082b9b219218b6571..96cc3a408cfe3659b8e5c306a8bef402ba0f11ba 100644 (file)
@@ -347,6 +347,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 0e13ec619b432b9edd7a792bebe255ab3deb8a0e..b7e5c4082b1c85d3cd67ddbe67baec3f15fdff13 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;
@@ -446,7 +446,8 @@ 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 351c8038ed7f0815e346239bb5267a606c540d3f..fb95b04e608ba2c3de7d96a453fac139aca32dea 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);
+
+       g_signal_connect(G_OBJECT(key_custom), "toggled", G_CALLBACK(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 2952e4a2e8ba93f842cd433ffb41516861d2bbba..c9ad350a5fa8c7956bd96242eec1624fc51fc176 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 c1e5aa3831503b4c0f6335e22a7e9f0a8297461d..a90f8e9bbf6d29c79cafc4d2d0552e5a9ee3e563 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 70f86a24193d5ff35dae9284e7e9fd10341f4d00..736ecc73c2f4c151f5c1255a4d8b9c413204f65f 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 83cb8c4646569ac99abdd7844d9d93cfabe86b39..3cb7c1d06fd5384503a83e4e735633165ea6130d 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,7 +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 */
        {"ssl_pop", "0", &tmp_ac_prefs.ssl_pop, P_ENUM,
@@ -554,6 +561,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);
+       g_object_set_data(G_OBJECT(menuitem), MENU_VAL_ID, "");
+       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);
+               g_object_set_data_full(G_OBJECT(menuitem), MENU_VAL_ID, 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_current_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 +689,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 +698,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 +719,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 +772,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 +807,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 +861,18 @@ 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);
-       g_object_set_data(G_OBJECT(menuitem), MENU_VAL_ID, "");
-       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);
-               g_object_set_data_full(G_OBJECT(menuitem), MENU_VAL_ID, id, g_free);
-               gtk_menu_append(GTK_MENU(menu), menuitem);
-       }
+void destroy_dialog(gpointer data)
+{
+       PrefsAccount *ac_prefs = (PrefsAccount *) data;
+       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 +881,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_current_page(GTK_NOTEBOOK(dialog.notebook), 0);
-       gtk_widget_grab_focus(dialog.ok_btn);
-
-       tmp_ac_prefs = *ac_prefs;
-
-       update_privacy_system_menu();
-
-       if (new_account) {
-               PrefsAccount *def_ac;
-               gchar *buf;
+       } else
+               new_account = FALSE;
 
-               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 +914,33 @@ static void prefs_account_create(void)
 
        debug_print("Creating account preferences window...\n");
 
-       /* create dialog */
-       prefs_dialog_create(&dialog);
-       g_signal_connect(G_OBJECT(dialog.window), "delete_event",
-                        G_CALLBACK(prefs_account_deleted), NULL);
-       g_signal_connect(G_OBJECT(dialog.window), "key_press_event",
-                        G_CALLBACK(prefs_account_key_pressed), NULL);
-       MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
-
-       g_signal_connect(G_OBJECT(dialog.ok_btn), "clicked",
-                        G_CALLBACK(prefs_account_ok), NULL);
-       g_signal_connect(G_OBJECT(dialog.apply_btn), "clicked",
-                        G_CALLBACK(prefs_account_apply), NULL);
-       g_signal_connect(G_OBJECT(dialog.cancel_btn), "clicked",
-                        G_CALLBACK(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 +1012,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 +1301,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 +1518,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 +1708,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"));
@@ -1697,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);
@@ -1793,7 +1936,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"));
@@ -1999,7 +2142,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);
@@ -2915,3 +3058,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 5f71af6250c67eb7213fcf818b53f5df250b2d25..09a8dc8ff5cee437061c9588ae3b0db5e1388350 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,6 +46,7 @@ typedef enum {
 
 #include "smtp.h"
 #include "folder.h"
+#include "gtk/prefswindow.h"
 
 struct _PrefsAccount
 {
@@ -173,8 +174,11 @@ 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,
@@ -185,4 +189,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 aeeb030ec1346b45c8f27aa15740719b6cf6d8bb..27d0cf2d81fe94605190c960c4522ea210d80cd4 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 c3222036f86beeb85387fe090c2dee534de05e57..90c3c7b6ad8a53d846d847202134a95a17926086 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);
index 8bdc279965318dfc8ed1965dd17beb08da821d65..c74dae89b38ebd18a7021f0f6f18216dce6cac21 100644 (file)
@@ -45,7 +45,6 @@
 #include "codeconv.h"
 #include "utils.h"
 #include "prefs_common.h"
-
 #include "prefs_gtk.h"
 
 static GHashTable *procmime_get_mime_type_table        (void);
@@ -1660,11 +1659,18 @@ typedef enum {
     ENC_AS_EXTENDED,
 } EncodeAs;
 
+typedef struct _ParametersData {
+       FILE *fp;
+       guint len;
+} ParametersData;
+
 static void write_parameters(gpointer key, gpointer value, gpointer user_data)
 {
        gchar *param = key;
        gchar *val = value, *valpos;
-       FILE *fp = user_data;
+       ParametersData *pdata = (ParametersData *)user_data;
+       GString *buf = g_string_new("");
+
        EncodeAs encas = ENC_AS_TOKEN;
 
        for (valpos = val; *valpos != 0; valpos++) {
@@ -1704,43 +1710,60 @@ static void write_parameters(gpointer key, gpointer value, gpointer user_data)
 
        switch (encas) {
        case ENC_AS_TOKEN:
-               fprintf(fp, "; %s=", param);
-               fprintf(fp, "%s", val);
+               g_string_append_printf(buf, "%s=%s", param, val);
                break;
 
        case ENC_AS_QUOTED_STRING:
-               fprintf(fp, "; %s=", param);
-               fprintf(fp, "\"%s\"", val);
+               g_string_append_printf(buf, "%s=\"%s\"", param, val);
                break;
 
        case ENC_AS_EXTENDED:
-               fprintf(fp, "; %s*=", param);
-               fprintf(fp, "%s''", conv_get_current_charset_str());
+               g_string_append_printf(buf, "%s*=%s''", param,
+                       conv_get_current_charset_str());
                for (valpos = val; *valpos != '\0'; valpos++) {
-                       if (IS_ASCII(*valpos) && isalnum(*valpos))
-                               fprintf(fp, "%c", *valpos);
-                       else {
+                       if (IS_ASCII(*valpos) && isalnum(*valpos)) {
+                               g_string_append_printf(buf, "%c", *valpos);
+                       else {
                                gchar hexstr[3] = "XX";
                                get_hex_str(hexstr, *valpos);
-                               fprintf(fp, "%%%s", hexstr);
+                               g_string_append_printf(buf, "%%%s", hexstr);
                        }
                }
                break;
        }
+       
+       if (buf->str && strlen(buf->str)) {
+               if (pdata->len + strlen(buf->str) + 2 > 76) {
+                       fprintf(pdata->fp, ";\n %s", buf->str);
+                       pdata->len = strlen(buf->str) + 1;
+               } else {
+                       fprintf(pdata->fp, "; %s", buf->str);
+                       pdata->len += strlen(buf->str) + 2;
+               }
+       }
+       g_string_free(buf, TRUE);
 }
 
 void procmime_write_mime_header(MimeInfo *mimeinfo, FILE *fp)
 {
        struct TypeTable *type_table;
-
+       ParametersData *pdata = g_new0(ParametersData, 1);
        debug_print("procmime_write_mime_header\n");
+       
+       pdata->fp = fp;
 
        for (type_table = mime_type_table; type_table->str != NULL; type_table++)
                if (mimeinfo->type == type_table->type) {
-                       fprintf(fp, "Content-Type: %s/%s", type_table->str, mimeinfo->subtype);
+                       gchar *buf = g_strdup_printf(
+                               "Content-Type: %s/%s", type_table->str, mimeinfo->subtype);
+                       fprintf(fp, buf);
+                       pdata->len = strlen(buf);
+                       g_free(buf);
                        break;
                }
-       g_hash_table_foreach(mimeinfo->typeparameters, write_parameters, fp);
+       g_hash_table_foreach(mimeinfo->typeparameters, write_parameters, pdata);
+       g_free(pdata);
+
        fprintf(fp, "\n");
 
        if (mimeinfo->encoding_type != ENC_UNKNOWN)
@@ -1753,16 +1776,22 @@ void procmime_write_mime_header(MimeInfo *mimeinfo, FILE *fp)
                fprintf(fp, "Content-ID: %s\n", mimeinfo->id);
 
        if (mimeinfo->disposition != DISPOSITIONTYPE_UNKNOWN) {
-               fprintf(fp, "Content-Disposition: ");
+               ParametersData *pdata = g_new0(ParametersData, 1);
+               gchar *buf = NULL;
                if (mimeinfo->disposition == DISPOSITIONTYPE_INLINE)
-                       fprintf(fp, "inline");
+                       buf = g_strdup("Content-Disposition: inline");
                else if (mimeinfo->disposition == DISPOSITIONTYPE_ATTACHMENT)
-                       fprintf(fp, "attachment");
+                       buf = g_strdup("Content-Disposition: attachment");
                else
-                       fprintf(fp, "unknown");
+                       buf = g_strdup("Content-Disposition: unknown");
+
+               fprintf(fp, "%s", buf);
+               pdata->len = strlen(buf);
+               g_free(buf);
 
-               /* FIXME: linebreaks after too many parameters */
-               g_hash_table_foreach(mimeinfo->dispositionparameters, write_parameters, fp);
+               pdata->fp = fp;
+               g_hash_table_foreach(mimeinfo->dispositionparameters, write_parameters, pdata);
+               g_free(pdata);
                fprintf(fp, "\n");
        }