~ubuntu-branches/ubuntu/wily/evolution/wily

« back to all changes in this revision

Viewing changes to em-format/e-mail-formatter-quote.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-07-03 23:07:40 UTC
  • mfrom: (1.1.92)
  • Revision ID: package-import@ubuntu.com-20120703230740-0hjh6kfpxsyb88gx
Tags: 3.5.3.1-0ubuntu1
* New upstream release 3.5.3.1.
* debian/control:
  - Add libwebkitgtk-3.0-dev, libjavascriptcoregtk-3.0-dev >= 1.8.0 to build
    dependencies.
  - Adjust Build-Depends for the new minimum versions required for EDS 3.5.
  - Also update evolution's Depends to require evolution-data-server >= 3.5,
    and << 3.6.
* debian/rules:
  - Update ELIBDIR to point to /usr/lib/evolution/3.6 now, as per the base
    version defined in configure.
  - Build all plugins rather than enabling experimental specifically; we can
    sort them to other packages after.
  - Drop the binary-install/evolution-common target.
* debian/patches/01_ubuntu_signature.patch: dropped; upstream code has changed
  sufficiently that it would pretty much need a rewrite; and Evolution is no
  longer the default shipped mail client on Desktop.
* debian/patches/04_delay_alarm_notifier.patch: refreshed.
* debian/patches/89_remove_component_id_registration.patch: dropped: we don't
  have UNE anymore and component ID registration has been moved to GSettings.
* debian/patches/10_revert_libevolution_avoid-version.patch: refreshed.
* debian/patches/91_add_u1_email_translations.patch: refreshed.
* debian/evolution-common.install:
  - Drop debian/signature.py.
  - Don't install /usr/share/mime-info; it's not built anymore.
* debian/signature.py: dropped; since we dropped the Ubuntu signature patch.
* debian/evolution.install: don't try to install files in /etc/gconf; evo
  has migrated to GSettings so there are no such files anymore.
* debian/evolution.install,
  debian/evolution-plugins.install,
  debian/evolution-plugins-experimental.install: remove the plugins that were
  converted to modules. Modules are already installed by libevolution.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * e-mail-formatter-quote.c
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) version 3.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with the program; if not, see <http://www.gnu.org/licenses/>
 
16
 *
 
17
 */
 
18
 
 
19
#include "e-mail-formatter-quote.h"
 
20
 
 
21
#include <camel/camel.h>
 
22
 
 
23
#include "e-mail-formatter-extension.h"
 
24
#include "e-mail-format-extensions.h"
 
25
#include "e-mail-part.h"
 
26
#include "e-mail-part-attachment.h"
 
27
#include "e-mail-part-utils.h"
 
28
 
 
29
#include <libebackend/libebackend.h>
 
30
#include <gdk/gdk.h>
 
31
#include <glib/gi18n.h>
 
32
 
 
33
struct _EMailFormatterQuotePrivate {
 
34
        gchar *credits;
 
35
        EMailFormatterQuoteFlags flags;
 
36
};
 
37
 
 
38
#define E_MAIL_FORMATTER_QUOTE_GET_PRIVATE(obj) \
 
39
        (G_TYPE_INSTANCE_GET_PRIVATE \
 
40
        ((obj), E_TYPE_MAIL_FORMATTER_QUOTE, EMailFormatterQuotePrivate))
 
41
 
 
42
static gpointer e_mail_formatter_quote_parent_class = 0;
 
43
 
 
44
static EMailFormatterContext *
 
45
mail_formatter_quote_create_context (EMailFormatter *formatter)
 
46
{
 
47
        return g_malloc0 (sizeof (EMailFormatterQuoteContext));
 
48
}
 
49
 
 
50
static void
 
51
mail_formatter_quote_free_context (EMailFormatter *formatter,
 
52
                                   EMailFormatterContext *context)
 
53
{
 
54
        g_free ((EMailFormatterQuoteContext *) context);
 
55
}
 
56
 
 
57
static void
 
58
mail_formatter_quote_run (EMailFormatter *formatter,
 
59
                          EMailFormatterContext *context,
 
60
                          CamelStream *stream,
 
61
                          GCancellable *cancellable)
 
62
{
 
63
        EMailFormatterQuote *qf;
 
64
        EMailFormatterQuoteContext *qf_context;
 
65
        GSettings *settings;
 
66
        GSList *iter;
 
67
 
 
68
        if (g_cancellable_is_cancelled (cancellable))
 
69
                return;
 
70
 
 
71
        qf = E_MAIL_FORMATTER_QUOTE (formatter);
 
72
 
 
73
        qf_context = (EMailFormatterQuoteContext *) context;
 
74
        qf_context->qf_flags = qf->priv->flags;
 
75
 
 
76
        g_seekable_seek (
 
77
                G_SEEKABLE (stream),
 
78
                0, G_SEEK_SET, NULL, NULL);
 
79
 
 
80
        settings = g_settings_new ("org.gnome.evolution.mail");
 
81
        if (g_settings_get_boolean (
 
82
                settings, "composer-top-signature"))
 
83
                camel_stream_write_string (
 
84
                        stream, "<br>\n", cancellable, NULL);
 
85
        g_object_unref (settings);
 
86
 
 
87
        if (qf->priv->credits && *qf->priv->credits) {
 
88
                gchar *credits = g_strdup_printf ("%s<br/>", qf->priv->credits);
 
89
                camel_stream_write_string (stream, credits, cancellable, NULL);
 
90
                g_free (credits);
 
91
        } else {
 
92
                camel_stream_write_string (stream, "<br/>", cancellable, NULL);
 
93
        }
 
94
 
 
95
        if (qf->priv->flags & E_MAIL_FORMATTER_QUOTE_FLAG_CITE) {
 
96
                camel_stream_write_string (stream,
 
97
                        "<!--+GtkHTML:<DATA class=\"ClueFlow\" "
 
98
                        "key=\"orig\" value=\"1\">-->\n"
 
99
                        "<blockquote type=cite>\n", cancellable, NULL);
 
100
        }
 
101
 
 
102
        for (iter = context->parts; iter; iter = iter->next) {
 
103
                EMailPart *part = iter->data;
 
104
 
 
105
                if (!part)
 
106
                        continue;
 
107
 
 
108
                if (g_str_has_suffix (part->id, ".headers") &&
 
109
                   !(qf_context->qf_flags & E_MAIL_FORMATTER_QUOTE_FLAG_HEADERS)) {
 
110
                        continue;
 
111
                }
 
112
 
 
113
                if (g_str_has_suffix (part->id, ".rfc822")) {
 
114
                        gchar *end = g_strconcat (part->id, ".end", NULL);
 
115
 
 
116
                        while (iter) {
 
117
                                EMailPart *p = iter->data;
 
118
                                if (!p) {
 
119
                                        iter = iter->next;
 
120
                                        continue;
 
121
                                }
 
122
 
 
123
                                if (g_strcmp0 (p->id, end) == 0)
 
124
                                        break;
 
125
 
 
126
                                iter = iter->next;
 
127
                        }
 
128
                        g_free (end);
 
129
                        continue;
 
130
                }
 
131
 
 
132
                if (part->is_hidden)
 
133
                        continue;
 
134
 
 
135
                e_mail_formatter_format_as (
 
136
                        formatter, context, part, stream,
 
137
                        part->mime_type, cancellable);
 
138
        }
 
139
 
 
140
        if (qf->priv->flags & E_MAIL_FORMATTER_QUOTE_FLAG_CITE) {
 
141
                camel_stream_write_string (
 
142
                        stream, "</blockquote><!--+GtkHTML:"
 
143
                        "<DATA class=\"ClueFlow\" clear=\"orig\">-->",
 
144
                        cancellable, NULL);
 
145
        }
 
146
}
 
147
 
 
148
static void
 
149
e_mail_formatter_quote_init (EMailFormatterQuote *formatter)
 
150
{
 
151
        formatter->priv = E_MAIL_FORMATTER_QUOTE_GET_PRIVATE (formatter);
 
152
}
 
153
 
 
154
static void
 
155
e_mail_formatter_quote_finalize (GObject *object)
 
156
{
 
157
        /* Chain up to parent's finalize() */
 
158
        G_OBJECT_CLASS (e_mail_formatter_quote_parent_class)->finalize (object);
 
159
}
 
160
 
 
161
static void
 
162
e_mail_formatter_quote_base_init (EMailFormatterQuoteClass *class)
 
163
{
 
164
        e_mail_formatter_quote_internal_extensions_load (
 
165
                E_MAIL_EXTENSION_REGISTRY (
 
166
                        E_MAIL_FORMATTER_CLASS (class)->extension_registry));
 
167
 
 
168
        E_MAIL_FORMATTER_CLASS (class)->text_html_flags =
 
169
                CAMEL_MIME_FILTER_TOHTML_PRE |
 
170
                CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS |
 
171
                CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES;
 
172
}
 
173
 
 
174
static void
 
175
e_mail_formatter_quote_class_init (EMailFormatterQuoteClass *class)
 
176
{
 
177
        GObjectClass *object_class;
 
178
        EMailFormatterClass *formatter_class;
 
179
 
 
180
        e_mail_formatter_quote_parent_class = g_type_class_peek_parent (class);
 
181
        g_type_class_add_private (class, sizeof (EMailFormatterQuotePrivate));
 
182
 
 
183
        formatter_class = E_MAIL_FORMATTER_CLASS (class);
 
184
        formatter_class->run = mail_formatter_quote_run;
 
185
        formatter_class->create_context = mail_formatter_quote_create_context;
 
186
        formatter_class->free_context = mail_formatter_quote_free_context;
 
187
 
 
188
        object_class = G_OBJECT_CLASS (class);
 
189
        object_class->finalize = e_mail_formatter_quote_finalize;
 
190
}
 
191
 
 
192
GType
 
193
e_mail_formatter_quote_get_type (void)
 
194
{
 
195
        static GType type = 0;
 
196
 
 
197
        if (G_UNLIKELY (type == 0)) {
 
198
                const GTypeInfo type_info = {
 
199
                        sizeof (EMailFormatterClass),
 
200
                        (GBaseInitFunc) e_mail_formatter_quote_base_init,
 
201
                        (GBaseFinalizeFunc) NULL,
 
202
                        (GClassInitFunc) e_mail_formatter_quote_class_init,
 
203
                        (GClassFinalizeFunc) NULL,
 
204
                        NULL,   /* class_data */
 
205
                        sizeof (EMailFormatterQuote),
 
206
                        0,      /* n_preallocs */
 
207
                        (GInstanceInitFunc) e_mail_formatter_quote_init,
 
208
                        NULL    /* value_table */
 
209
                };
 
210
 
 
211
                type = g_type_register_static (E_TYPE_MAIL_FORMATTER,
 
212
                                "EMailFormatterQuote", &type_info, 0);
 
213
        }
 
214
 
 
215
        return type;
 
216
}
 
217
 
 
218
EMailFormatter *
 
219
e_mail_formatter_quote_new (const gchar *credits,
 
220
                            EMailFormatterQuoteFlags flags)
 
221
{
 
222
        EMailFormatterQuote *formatter;
 
223
        formatter = g_object_new (E_TYPE_MAIL_FORMATTER_QUOTE, NULL);
 
224
 
 
225
        formatter->priv->credits = g_strdup (credits);
 
226
        formatter->priv->flags = flags;
 
227
 
 
228
        return (EMailFormatter *) formatter;
 
229
}