gboolean written_prefix;
gsize linkify_limit;
gsize full_limit;
+ gsize line_limit;
gsize total_output;
+ gsize total_lines_output;
};
#define MODEST_STREAM_TEXT_TO_HTML_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_STREAM_TEXT_TO_HTML, \
priv->linkify_limit = 0;
priv->full_limit = 0;
priv->total_output = 0;
+ priv->total_lines_output = 0;
+ modest_text_utils_hyperlinkify_begin ();
}
static void
if (priv->line_buffer != NULL) {
g_string_free (priv->line_buffer, TRUE);
}
+ modest_text_utils_hyperlinkify_end ();
}
GObject*
}
void
+modest_stream_text_to_html_set_line_limit (ModestStreamTextToHtml *self, gssize limit)
+{
+ ModestStreamTextToHtmlPrivate *priv = MODEST_STREAM_TEXT_TO_HTML_GET_PRIVATE (self);
+ priv->line_limit = limit;
+}
+
+void
modest_stream_text_to_html_set_linkify_limit (ModestStreamTextToHtml *self, gssize limit)
{
ModestStreamTextToHtmlPrivate *priv = MODEST_STREAM_TEXT_TO_HTML_GET_PRIVATE (self);
preserve the prefix and suffix */
if (convert_to_html && (priv->full_limit > 0) &&(priv->total_output > priv->full_limit))
return TRUE;
+ if (convert_to_html && (priv->line_limit > 0) && (priv->total_lines_output > priv->line_limit))
+ return TRUE;
if ((priv->linkify_limit > 0) && (priv->total_output > priv->linkify_limit))
hyperlinkify = FALSE;
if (convert_to_html) {
pending_bytes = strlen (html_buffer);
priv->total_output += pending_bytes;
+ priv->total_lines_output ++;
offset = html_buffer;
while (pending_bytes > 0) {
while (n > 0) {
gchar c = *buffer;
+
+ if ((priv->full_limit > 0) && (priv->total_output > priv->full_limit))
+ return n;
+ if ((priv->line_limit > 0) && (priv->total_lines_output > priv->line_limit))
+ return n;
+
if (priv->line_buffer == NULL)
priv->line_buffer = g_string_new (NULL);
klass = (TnyStreamIface*) g_iface;
- klass->read_func = text_to_html_read;
- klass->write_func = text_to_html_write;
- klass->flush_func = text_to_html_flush;
- klass->close_func = text_to_html_close;
- klass->is_eos_func = text_to_html_is_eos;
- klass->reset_func = text_to_html_reset;
- klass->write_to_stream_func = text_to_html_write_to_stream;
+ klass->read = text_to_html_read;
+ klass->write = text_to_html_write;
+ klass->flush = text_to_html_flush;
+ klass->close = text_to_html_close;
+ klass->is_eos = text_to_html_is_eos;
+ klass->reset = text_to_html_reset;
+ klass->write_to_stream = text_to_html_write_to_stream;
}