2005-07-01 [colin] 1.9.12cvs8
[claws.git] / src / compose.c
index 1152189eb1af7af6c6cfe3def2545d01c79e1191..84c0592b8bbfee63dee0707849e4d03ea0b1c2c5 100644 (file)
@@ -904,6 +904,30 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
         return compose;
 }
 
+static void compose_force_encryption(Compose *compose, PrefsAccount *account,
+               gboolean override_pref)
+{
+       gchar *privacy = NULL;
+
+       if (override_pref == FALSE && account->default_encrypt_reply == FALSE)
+               return;
+
+       if (account->default_privacy_system
+       &&  strlen(account->default_privacy_system)) {
+               privacy = account->default_privacy_system;
+       } else {
+               GSList *privacy_avail = privacy_get_system_ids();
+               if (privacy_avail && g_slist_length(privacy_avail)) {
+                       privacy = (gchar *)(privacy_avail->data);
+               }
+       }
+       if (privacy != NULL) {
+               compose->privacy_system = g_strdup(privacy);
+               compose_update_privacy_system_menu_item(compose);
+               compose_use_encryption(compose, TRUE);
+       }
+}      
+
 void compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar *body)
 {
        MsgInfo *msginfo;
@@ -1092,6 +1116,9 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
                                  prefs_common.quotefmt,
                                  qmark, body);
        }
+       if (procmime_msginfo_is_encrypted(compose->replyinfo)) {
+               compose_force_encryption(compose, account, FALSE);
+       }
 
        if (account->auto_sig)
                compose_insert_sig(compose, FALSE);
@@ -1399,10 +1426,17 @@ void compose_reedit(MsgInfo *msginfo)
        g_signal_handlers_block_by_func(G_OBJECT(textbuf),
                                        G_CALLBACK(compose_changed_cb),
                                        compose);
-                                       
-       if ((fp = procmime_get_first_text_content(msginfo)) == NULL)
+       
+       if (procmime_msginfo_is_encrypted(msginfo)) {
+               fp = procmime_get_first_encrypted_text_content(msginfo);
+               if (fp) 
+                       compose_force_encryption(compose, account, TRUE);
+       } else
+               fp = procmime_get_first_text_content(msginfo);
+       if (fp == NULL)
                g_warning("Can't get text part\n");
-       else {
+
+       if (fp != NULL) {
                gboolean prev_autowrap = compose->autowrap;
 
                compose->autowrap = FALSE;
@@ -2516,13 +2550,7 @@ static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
        } else if (compose->mode == COMPOSE_REEDIT &&
                 child->type == MIMETYPE_APPLICATION &&
                 !g_ascii_strcasecmp(child->subtype, "pgp-encrypted")) {
-               AlertValue val;
-               val = alertpanel(_("Encrypted message"),
-                                _("Cannot re-edit an encrypted message. \n"
-                                  "Discard encrypted part?"),
-                                _("Yes"), _("No"), NULL);
-               if (val == G_ALERTDEFAULT) 
-                       encrypted = (MimeInfo *)child->node->parent->data;
+               encrypted = (MimeInfo *)child->node->parent->data;
        }
      
        child = (MimeInfo *) mimeinfo->node->children->data;
@@ -2702,6 +2730,7 @@ static gboolean compose_get_line_break_pos(GtkTextBuffer *buffer,
        gint pos = 0;
        gboolean can_break = FALSE;
        gboolean do_break = FALSE;
+       gboolean was_white = FALSE;
 
        gtk_text_iter_forward_to_line_end(&line_end);
        str = gtk_text_buffer_get_text(buffer, &iter, &line_end, FALSE);
@@ -2735,8 +2764,10 @@ static gboolean compose_get_line_break_pos(GtkTextBuffer *buffer,
                gunichar wc;
                gint uri_len;
 
-               if (attr->is_line_break && can_break)
+               if (attr->is_line_break && can_break && was_white)
                        pos = i;
+               
+               was_white = attr->is_white;
 
                /* don't wrap URI */
                if ((uri_len = get_uri_len(p)) > 0) {
@@ -4804,6 +4835,7 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
        handlebox = gtk_handle_box_new();
        gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
 
+       gtk_widget_realize(handlebox);
        compose->toolbar = toolbar_create(TOOLBAR_COMPOSE, handlebox,
                                          (gpointer)compose);