2004-11-09 [christoph] 0.9.12cvs144
authorChristoph Hohmann <reboot@gmx.ch>
Tue, 9 Nov 2004 14:36:54 +0000 (14:36 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Tue, 9 Nov 2004 14:36:54 +0000 (14:36 +0000)
* src/compose.c
* src/prefs_account.[ch]
add option menu to select default privacy system

* src/plugins/pgpmime/pgpmime.c
better memory allocation

* src/folder.c
syncronize flags when scanning a folder

ChangeLog.claws
PATCHSETS
configure.ac
src/compose.c
src/folder.c
src/plugins/pgpmime/pgpmime.c
src/prefs_account.c
src/prefs_account.h

index f2618f1..74760d4 100644 (file)
@@ -1,3 +1,15 @@
+2004-11-09 [christoph] 0.9.12cvs144
+
+       * src/compose.c
+       * src/prefs_account.[ch]
+               add option menu to select default privacy system
+
+       * src/plugins/pgpmime/pgpmime.c
+               better memory allocation
+
+       * src/folder.c
+               syncronize flags when scanning a folder
+
 2004-11-08 [colin]     0.9.12cvs143
 
        * src/summaryview.c
index 114208c..7d3ffa7 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.126 -r 1.127 src/textview.c; ) > 0.9.12cvs141.patchset
 ( cvs diff -u -r 1.127 -r 1.128 src/textview.c; ) > 0.9.12cvs142.patchset
 ( cvs diff -u -r 1.449 -r 1.450 src/summaryview.c; ) > 0.9.12cvs143.patchset
+( cvs diff -u -r 1.453 -r 1.454 src/compose.c; cvs diff -u -r 1.261 -r 1.262 src/folder.c; cvs diff -u -r 1.312 -r 1.313 src/mainwindow.c; cvs diff -u -r 1.116 -r 1.117 src/prefs_account.c; cvs diff -u -r 1.53 -r 1.54 src/prefs_account.h; cvs diff -u -r 1.8 -r 1.9 src/plugins/pgpmime/pgpmime.c; ) > 0.9.12cvs144.patchset
index ae85987..133f770 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=143
+EXTRA_VERSION=144
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index 841b80a..bba250c 100644 (file)
@@ -6445,12 +6445,8 @@ static void compose_toggle_encrypt_cb(gpointer data, guint action,
 
 static void activate_privacy_system(Compose *compose, PrefsAccount *account) 
 {
-       /* TODO
-       if (account->default_gnupg_mode)
-               compose->gnupg_mode = GNUPG_MODE_INLINE;
-       else
-               compose->gnupg_mode = GNUPG_MODE_DETACH;
-       */              
+       g_free(compose->privacy_system);
+       compose->privacy_system = g_strdup(account->default_privacy_system);
        compose_update_privacy_system_menu_item(compose);
 }
 
index 130858e..9fc18b5 100644 (file)
@@ -1526,6 +1526,50 @@ static MsgInfo *get_msginfo(FolderItem *item, guint num)
        return msginfo;
 }
 
+static gint syncronize_flags(FolderItem *item, MsgInfoList *msglist)
+{
+       GRelation *relation;
+       gint ret = 0;
+       GSList *cur;
+
+       if(msglist == NULL)
+               return 0;
+       if(item->folder->klass->get_flags == NULL)
+               return 0;
+
+       relation = g_relation_new(2);
+       g_relation_index(relation, 0, g_direct_hash, g_direct_equal);
+       if ((ret = item->folder->klass->get_flags(
+           item->folder, item, msglist, relation)) == 0) {
+               GTuples *tuples;
+               MsgInfo *msginfo;
+               MsgPermFlags permflags;
+               gboolean skip;
+
+               for (cur = msglist; cur != NULL; cur = g_slist_next(cur)) {
+                       msginfo = (MsgInfo *) cur->data;
+               
+                       tuples = g_relation_select(relation, msginfo, 0);
+                       skip = tuples->len < 1;
+                       if (!skip)
+                               permflags = GPOINTER_TO_INT(g_tuples_index(tuples, 0, 1));
+                       g_tuples_destroy(tuples);
+                       if (skip)
+                               continue;
+                       
+                       if (msginfo->flags.perm_flags != permflags) {
+                               procmsg_msginfo_set_flags(msginfo,
+                                       permflags & ~msginfo->flags.perm_flags, 0);
+                               procmsg_msginfo_unset_flags(msginfo,
+                                       ~permflags & msginfo->flags.perm_flags, 0);
+                       }
+               }
+       }
+       g_relation_destroy(relation);   
+
+       return ret;
+}
+
 gint folder_item_scan_full(FolderItem *item, gboolean filtering)
 {
        Folder *folder;
@@ -1704,6 +1748,8 @@ gint folder_item_scan_full(FolderItem *item, gboolean filtering)
                g_slist_free(new_list);
        }
 
+       syncronize_flags(item, exists_list);
+
        folder_item_update_freeze();
        if (newmsg_list != NULL) {
                GSList *elem;
@@ -1767,60 +1813,6 @@ gint folder_item_scan_full(FolderItem *item, gboolean filtering)
        return 0;
 }
 
-gint folder_item_syncronize_flags(FolderItem *item)
-{
-       MsgInfoList *msglist = NULL;
-       GSList *cur;
-       GRelation *relation;
-       gint ret = 0;
-       
-       g_return_val_if_fail(item != NULL, -1);
-       g_return_val_if_fail(item->folder != NULL, -1);
-       g_return_val_if_fail(item->folder->klass != NULL, -1);
-       if(item->folder->klass->get_flags == NULL)
-               return 0;
-       
-       if (item->cache == NULL)
-               folder_item_read_cache(item);
-       
-       msglist = msgcache_get_msg_list(item->cache);
-       
-       relation = g_relation_new(2);
-       g_relation_index(relation, 0, g_direct_hash, g_direct_equal);
-       if ((ret = item->folder->klass->get_flags(
-           item->folder, item, msglist, relation)) == 0) {
-               GTuples *tuples;
-               MsgInfo *msginfo;
-               MsgPermFlags permflags;
-               gboolean skip;
-
-               for (cur = msglist; cur != NULL; cur = g_slist_next(cur)) {
-                       msginfo = (MsgInfo *) cur->data;
-               
-                       tuples = g_relation_select(relation, msginfo, 0);
-                       skip = tuples->len < 1;
-                       if (!skip)
-                               permflags = GPOINTER_TO_INT(g_tuples_index(tuples, 0, 1));
-                       g_tuples_destroy(tuples);
-                       if (skip)
-                               continue;
-                       
-                       if (msginfo->flags.perm_flags != permflags) {
-                               procmsg_msginfo_set_flags(msginfo,
-                                       permflags & ~msginfo->flags.perm_flags, 0);
-                               procmsg_msginfo_unset_flags(msginfo,
-                                       ~permflags & msginfo->flags.perm_flags, 0);
-                       }
-               }
-       }
-       g_relation_destroy(relation);
-       
-       for (cur = msglist; cur != NULL; cur = g_slist_next(cur))
-               procmsg_msginfo_free((MsgInfo *) cur->data);
-       
-       return ret;
-}
-
 gint folder_item_scan(FolderItem *item)
 {
        return folder_item_scan_full(item, TRUE);
@@ -1862,6 +1854,29 @@ void folder_count_total_cache_memusage(FolderItem *item, gpointer data)
        *memusage += msgcache_get_memory_usage(item->cache);
 }
 
+gint folder_item_syncronize_flags(FolderItem *item)
+{
+       MsgInfoList *msglist = NULL;
+       GSList *cur;
+       gint ret = 0;
+       
+       g_return_val_if_fail(item != NULL, -1);
+       g_return_val_if_fail(item->folder != NULL, -1);
+       g_return_val_if_fail(item->folder->klass != NULL, -1);
+       
+       if (item->cache == NULL)
+               folder_item_read_cache(item);
+       
+       msglist = msgcache_get_msg_list(item->cache);
+       
+       ret = syncronize_flags(item, msglist);
+
+       for (cur = msglist; cur != NULL; cur = g_slist_next(cur))
+               procmsg_msginfo_free((MsgInfo *) cur->data);
+       
+       return ret;
+}
+
 gint folder_cache_time_compare_func(gconstpointer a, gconstpointer b)
 {
        FolderItem *fa = (FolderItem *)a;
index b696b28..f1189bb 100644 (file)
@@ -472,7 +472,8 @@ gboolean pgpmime_sign(MimeInfo *mimeinfo)
        newinfo->type = MIMETYPE_APPLICATION;
        newinfo->subtype = g_strdup("pgp-signature");
        newinfo->content = MIMECONTENT_MEM;
-       newinfo->data.mem = g_memdup(sigcontent, len + 1);
+       newinfo->data.mem = g_malloc(len + 1);
+       g_memmove(newinfo->data.mem, sigcontent, len);
        newinfo->data.mem[len] = '\0';
        g_node_append(sigmultipart->node, newinfo->node);
 
@@ -565,7 +566,8 @@ gboolean pgpmime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
        newinfo->type = MIMETYPE_APPLICATION;
        newinfo->subtype = g_strdup("octet-stream");
        newinfo->content = MIMECONTENT_MEM;
-       newinfo->data.mem = g_memdup(enccontent, len + 1);
+       newinfo->data.mem = g_malloc(len);
+       g_memmove(newinfo->data.mem, enccontent, len);
        newinfo->data.mem[len] = '\0';
        g_node_append(encmultipart->node, newinfo->node);
 
index c3e66f7..6da3274 100644 (file)
@@ -136,6 +136,7 @@ static struct Compose {
 } compose;
 
 static struct Privacy {
+       GtkWidget *default_privacy_system;
        GtkWidget *default_encrypt_chkbtn;
        GtkWidget *default_sign_chkbtn;
 } privacy;
@@ -201,6 +202,9 @@ static void prefs_account_protocol_set_data_from_optmenu(PrefParam *pparam);
 static void prefs_account_protocol_set_optmenu         (PrefParam *pparam);
 static void prefs_account_protocol_activated           (GtkMenuItem *menuitem);
 
+static void prefs_account_set_string_from_optmenu      (PrefParam *pparam);
+static void prefs_account_set_optmenu_from_string      (PrefParam *pparam);
+
 static void prefs_account_imap_auth_type_set_data_from_optmenu
                                                        (PrefParam *pparam);
 static void prefs_account_imap_auth_type_set_optmenu   (PrefParam *pparam);
@@ -391,6 +395,9 @@ static PrefParam param[] = {
         prefs_set_data_from_entry, prefs_set_entry},
 
        /* Privacy */
+       {"default_privacy_system", "", &tmp_ac_prefs.default_privacy_system, P_STRING,
+        &privacy.default_privacy_system,
+        prefs_account_set_string_from_optmenu, prefs_account_set_optmenu_from_string},
        {"default_encrypt", "FALSE", &tmp_ac_prefs.default_encrypt, P_BOOL,
         &privacy.default_encrypt_chkbtn,
         prefs_set_data_from_toggle, prefs_set_toggle},
@@ -629,6 +636,33 @@ 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);
+
+       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);
+}
+
 PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs)
 {
        gboolean new_account = FALSE;
@@ -657,6 +691,8 @@ PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs)
 
        tmp_ac_prefs = *ac_prefs;
 
+       update_privacy_system_menu();
+
        if (new_account) {
                PrefsAccount *def_ac;
                gchar *buf;
@@ -1632,6 +1668,9 @@ static void prefs_account_privacy_create(void)
 {
        GtkWidget *vbox1;
        GtkWidget *vbox2;
+       GtkWidget *hbox1;
+       GtkWidget *label;
+       GtkWidget *default_privacy_system;
        GtkWidget *default_encrypt_chkbtn;
        GtkWidget *default_sign_chkbtn;
 
@@ -1644,11 +1683,24 @@ static void prefs_account_privacy_create(void)
        gtk_widget_show (vbox2);
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
 
+       hbox1 = gtk_hbox_new(FALSE, 8);
+       gtk_widget_show (hbox1);
+       gtk_container_add (GTK_CONTAINER(vbox2), hbox1);
+
+       label = gtk_label_new(_("Default privacy system"));
+       gtk_widget_show(label);
+       gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
+
+       default_privacy_system = gtk_option_menu_new();
+       gtk_widget_show (default_privacy_system);
+       gtk_box_pack_start (GTK_BOX(hbox1), default_privacy_system, TRUE, TRUE, 0);
+
        PACK_CHECK_BUTTON (vbox2, default_encrypt_chkbtn,
                           _("Encrypt message by default"));
        PACK_CHECK_BUTTON (vbox2, default_sign_chkbtn,
                           _("Sign message by default"));
                            
+       privacy.default_privacy_system = default_privacy_system;
        privacy.default_encrypt_chkbtn = default_encrypt_chkbtn;
        privacy.default_sign_chkbtn    = default_sign_chkbtn;
 }
@@ -2356,6 +2408,72 @@ static void prefs_account_smtp_auth_type_set_optmenu(PrefParam *pparam)
        gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
 }
 
+static void prefs_account_set_string_from_optmenu(PrefParam *pparam)
+{
+       GtkWidget *menu;
+       GtkWidget *menuitem;
+       gchar **str;
+
+       g_return_if_fail(*pparam->widget != NULL);
+
+       menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
+       menuitem = gtk_menu_get_active(menu);
+       if (menuitem == NULL)
+               return;
+
+       str = (gchar **) pparam->data;
+        g_free(*str);
+       *str = g_strdup(gtk_object_get_user_data(menuitem));
+}
+
+static void prefs_account_set_optmenu_from_string(PrefParam *pparam)
+{
+       GtkWidget *optionmenu;
+       GtkWidget *menu;
+       gboolean found = FALSE;
+       GList *children, *cur;
+       gchar *prefsid;
+       guint i = 0;
+
+       g_return_if_fail(*pparam->widget != NULL);
+
+       prefsid = *((gchar **) pparam->data);
+       if (prefsid == NULL)
+               return;
+
+       optionmenu = *pparam->widget;
+       menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optionmenu));
+       children = gtk_container_children(GTK_CONTAINER(menu));
+       for (cur = children; cur != NULL; cur = g_list_next(cur)) {
+               GtkWidget *item = (GtkWidget *) cur->data;
+               gchar *id;
+
+               id = gtk_object_get_user_data(GTK_OBJECT(item));
+               if (id != NULL && strcmp(id, prefsid) == 0) {
+                       found = TRUE;
+/*                     gtk_menu_shell_select_item(GTK_MENU_SHELL(menu), item); */
+                       gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu), i);
+               }
+               i++;
+       }
+
+       if (!found) {
+               gchar *name;
+               GtkWidget *menuitem;
+
+               name = g_strdup_printf(_("Unsuppored (%s)"), prefsid);
+               menuitem = gtk_menu_item_new_with_label(name);
+               gtk_widget_show(menuitem);
+               gtk_object_set_data_full(GTK_OBJECT(menuitem), "user_data", g_strdup(prefsid), g_free);
+               gtk_menu_append(GTK_MENU(menu), menuitem);
+               g_free(name);
+
+               gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu), i);
+       }
+
+       g_list_free(children);
+}
+
 static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
 {
        RecvProtocol protocol;
index cb4edd1..690a345 100644 (file)
@@ -129,8 +129,9 @@ struct _PrefsAccount
        gchar    *auto_replyto;
 
        /* Privacy */
-       gboolean default_encrypt;
-       gboolean default_sign;
+       gchar    *default_privacy_system;
+       gboolean  default_encrypt;
+       gboolean  default_sign;
 
        /* Advanced */
        gboolean  set_smtpport;