static void compose_attach_parts (Compose *compose,
MsgInfo *msginfo);
-static void compose_wrap_paragraph (Compose *compose,
+static void compose_beautify_paragraph (Compose *compose,
GtkTextIter *par_iter,
gboolean force);
static void compose_wrap_all (Compose *compose);
}
}
+static void compose_force_signing(Compose *compose, PrefsAccount *account)
+{
+ gchar *privacy = NULL;
+
+ 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_signing(compose, TRUE);
+ }
+}
+
void compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar *body)
{
MsgInfo *msginfo;
return compose;
}
+static gboolean compose_is_sig_separator(Compose *compose, GtkTextBuffer *textbuf, GtkTextIter *iter)
+{
+ GtkTextIter start = *iter;
+ GtkTextIter end_iter;
+ int start_pos = gtk_text_iter_get_offset(&start);
+
+ if (!compose->account->sig_sep)
+ return FALSE;
+
+ gtk_text_buffer_get_iter_at_offset(textbuf, &end_iter,
+ start_pos+strlen(compose->account->sig_sep));
+
+ /* check sig separator */
+ if (!strcmp(gtk_text_iter_get_text(&start, &end_iter),
+ compose->account->sig_sep)) {
+ /* check end of line (\n) */
+ gtk_text_buffer_get_iter_at_offset(textbuf, &start,
+ start_pos+strlen(compose->account->sig_sep));
+ gtk_text_buffer_get_iter_at_offset(textbuf, &end_iter,
+ start_pos+strlen(compose->account->sig_sep)+1);
+
+ if (!strcmp(gtk_text_iter_get_text(&start, &end_iter),"\n"));
+ return TRUE;
+
+
+ }
+
+ return FALSE;
+}
+
+static void compose_colorize_signature(Compose *compose)
+{
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(compose->text));
+ GtkTextIter iter;
+ GtkTextIter end_iter;
+ gtk_text_buffer_get_start_iter(buffer, &iter);
+ while (gtk_text_iter_forward_line(&iter))
+ if (compose_is_sig_separator(compose, buffer, &iter)) {
+ gtk_text_buffer_get_end_iter(buffer, &end_iter);
+ gtk_text_buffer_apply_tag_by_name(buffer,"signature",&iter, &end_iter);
+ }
+}
+
void compose_reedit(MsgInfo *msginfo)
{
Compose *compose = NULL;
compose_attach_parts(compose, msginfo);
+ compose_colorize_signature(compose);
+
g_signal_handlers_unblock_by_func(G_OBJECT(textbuf),
G_CALLBACK(compose_changed_cb),
compose);
compose_quote_fmt(compose, msginfo, "%M", NULL, NULL);
gtk_text_view_set_editable(GTK_TEXT_VIEW(compose->text), FALSE);
+ compose_colorize_signature(compose);
+
ifactory = gtk_item_factory_from_widget(compose->popupmenu);
menu_set_sensitive(ifactory, "/Add...", FALSE);
menu_set_sensitive(ifactory, "/Remove", FALSE);
(prefs_common.color_new, &bold_color);
bold_style = gtk_style_copy(gtk_widget_get_style
(GTK_WIDGET(entry)));
- if (BOLD_FONT)
- font_desc = pango_font_description_from_string
- (BOLD_FONT);
- if (font_desc) {
- if (bold_style->font_desc)
- pango_font_description_free
- (bold_style->font_desc);
- bold_style->font_desc = font_desc;
- }
+ pango_font_description_set_weight
+ (bold_style->font_desc, PANGO_WEIGHT_BOLD);
bold_style->fg[GTK_STATE_NORMAL] = bold_color;
}
gtk_widget_set_style(GTK_WIDGET(entry), bold_style);
compose_ext_editor_cb(compose, 0, NULL);
break;
case A_LINEWRAP_CURRENT:
- compose_wrap_paragraph(compose, NULL, TRUE);
+ compose_beautify_paragraph(compose, NULL, TRUE);
break;
case A_LINEWRAP_ALL:
compose_wrap_all_full(compose, TRUE);
gchar *content_type;
content_type = procmime_get_content_type_str(child->type, child->subtype);
- partname = procmime_mimeinfo_get_parameter(child, "name");
- if (partname == NULL)
- partname = "";
- compose_attach_append(compose, outfile,
- partname, content_type);
+
+ /* if we meet a pgp signature, we don't attach it, but
+ * we force signing. */
+ if (strcmp(content_type, "application/pgp-signature")) {
+ partname = procmime_mimeinfo_get_parameter(child, "filename");
+ if (partname == NULL)
+ partname = procmime_mimeinfo_get_parameter(child, "name");
+ if (partname == NULL)
+ partname = "";
+ compose_attach_append(compose, outfile,
+ partname, content_type);
+ } else {
+ compose_force_signing(compose, compose->account);
+ }
g_free(content_type);
}
g_free(outfile);
return do_break;
}
-static gboolean compose_is_sig_separator(Compose *compose, GtkTextBuffer *textbuf, GtkTextIter *iter)
-{
- GtkTextIter start = *iter;
- GtkTextIter end_iter;
- int start_pos = gtk_text_iter_get_offset(&start);
-
- if (!compose->account->sig_sep)
- return FALSE;
-
- gtk_text_buffer_get_iter_at_offset(textbuf, &end_iter,
- start_pos+strlen(compose->account->sig_sep));
-
- /* check sig separator */
- if (!strcmp(gtk_text_iter_get_text(&start, &end_iter),
- compose->account->sig_sep)) {
- /* check end of line (\n) */
- gtk_text_buffer_get_iter_at_offset(textbuf, &start,
- start_pos+strlen(compose->account->sig_sep));
- gtk_text_buffer_get_iter_at_offset(textbuf, &end_iter,
- start_pos+strlen(compose->account->sig_sep)+1);
-
- if (!strcmp(gtk_text_iter_get_text(&start, &end_iter),"\n"));
- return TRUE;
-
-
- }
-
- return FALSE;
-}
-
static gboolean compose_join_next_line(Compose *compose,
GtkTextBuffer *buffer,
GtkTextIter *iter,
g_warning("alloc error scanning URIs\n"); \
}
-static void compose_wrap_paragraph(Compose *compose, GtkTextIter *par_iter, gboolean force)
+static void compose_beautify_paragraph(Compose *compose, GtkTextIter *par_iter, gboolean force)
{
GtkTextView *text = GTK_TEXT_VIEW(compose->text);
GtkTextBuffer *buffer;
const gint PARSE_ELEMS = sizeof parser / sizeof parser[0];
gint last_index = PARSE_ELEMS;
gint n;
- gchar *o_walk, *walk, *bp, *ep;
+ gchar *o_walk = NULL, *walk = NULL, *bp = NULL, *ep = NULL;
gint walk_pos;
if (gtk_text_iter_has_tag(&iter, no_wrap_tag) && !force)
}
goto colorize;
}
- debug_print("compose_wrap_paragraph(): quote_str = '%s'\n", quote_str);
+ debug_print("compose_beautify_paragraph(): quote_str = '%s'\n", quote_str);
startq_offset = gtk_text_iter_get_offset(&iter);
} else {
if (startq_offset == -1)
uri_stop = walk_pos + (ep - o_walk);
}
g_free(o_walk);
+ o_walk = NULL;
gtk_text_iter_forward_line(&iter);
g_free(quote_str);
+ quote_str = NULL;
if (startq_offset != -1) {
GtkTextIter startquote, endquote;
gtk_text_buffer_get_iter_at_offset(
gtk_text_buffer_get_start_iter(buffer, &iter);
while (!gtk_text_iter_is_end(&iter))
- compose_wrap_paragraph(compose, &iter, force);
+ compose_beautify_paragraph(compose, &iter, force);
undo_unblock(compose->undostruct);
}
val = compose_queue(compose, &msgnum, &folder);
if (val) {
- if (val == -2) {
+ if (val == -3) {
+ alertpanel_error(_("Could not queue message for sending:\n\n"
+ "Signature failed."));
+ } else if (val == -2) {
alertpanel_error(_("Could not queue message for sending:\n\n%s."), strerror(errno));
} else {
alertpanel_error(_("Could not queue message for sending."));
if (action == COMPOSE_WRITE_FOR_SEND && compose->use_signing &&
privacy_system_can_sign(compose->privacy_system))
if (!privacy_sign(compose->privacy_system, mimemsg, compose->account))
- return -1;
+ return -2;
procmime_write_mimeinfo(mimemsg, fp);
return -2;
}
} else {
- if (compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_SEND) < 0) {
+ gint result = 0;
+ if ((result = compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_SEND)) < 0) {
lock = FALSE;
fclose(fp);
g_unlink(tmp);
g_free(tmp);
- return -2;
+ return result - 1; /* -2 for a generic error, -3 for signing error */
}
}
if (action == 1)
compose_wrap_all_full(compose, TRUE);
else
- compose_wrap_paragraph(compose, NULL, TRUE);
+ compose_beautify_paragraph(compose, NULL, TRUE);
}
static void compose_toggle_autowrap_cb(gpointer data, guint action,
gtk_text_buffer_insert(buffer, iter, text, len);
mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE);
- compose_wrap_all_full(compose, FALSE);
+
+ compose_beautify_paragraph(compose, iter, FALSE);
+
gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
gtk_text_buffer_delete_mark(buffer, mark);