lib/index: generalize name of indexing filter

In followup commits we will generalize the functionality of this
filter to deal with other types of non-indexable content.
This commit is contained in:
David Bremner 2017-06-07 23:11:46 -03:00
parent d848d4040a
commit 20c15bc820

View file

@ -26,11 +26,11 @@
/* Oh, how I wish that gobject didn't require so much noisy boilerplate! /* Oh, how I wish that gobject didn't require so much noisy boilerplate!
* (Though I have at least eliminated some of the stock set...) */ * (Though I have at least eliminated some of the stock set...) */
typedef struct _NotmuchFilterDiscardUuencode NotmuchFilterDiscardUuencode; typedef struct _NotmuchFilterDiscardNonTerm NotmuchFilterDiscardNonTerm;
typedef struct _NotmuchFilterDiscardUuencodeClass NotmuchFilterDiscardUuencodeClass; typedef struct _NotmuchFilterDiscardNonTermClass NotmuchFilterDiscardNonTermClass;
/** /**
* NotmuchFilterDiscardUuencode: * NotmuchFilterDiscardNonTerm:
* *
* @parent_object: parent #GMimeFilter * @parent_object: parent #GMimeFilter
* @encode: encoding vs decoding * @encode: encoding vs decoding
@ -54,18 +54,18 @@ typedef struct _NotmuchFilterDiscardUuencodeClass NotmuchFilterDiscardUuencodeCl
* final line of encoded data (the line not starting with M) will be * final line of encoded data (the line not starting with M) will be
* indexed. * indexed.
**/ **/
struct _NotmuchFilterDiscardUuencode { struct _NotmuchFilterDiscardNonTerm {
GMimeFilter parent_object; GMimeFilter parent_object;
int state; int state;
}; };
struct _NotmuchFilterDiscardUuencodeClass { struct _NotmuchFilterDiscardNonTermClass {
GMimeFilterClass parent_class; GMimeFilterClass parent_class;
}; };
static GMimeFilter *notmuch_filter_discard_uuencode_new (void); static GMimeFilter *notmuch_filter_discard_non_term_new (void);
static void notmuch_filter_discard_uuencode_finalize (GObject *object); static void notmuch_filter_discard_non_term_finalize (GObject *object);
static GMimeFilter *filter_copy (GMimeFilter *filter); static GMimeFilter *filter_copy (GMimeFilter *filter);
static void filter_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace, static void filter_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace,
@ -78,14 +78,14 @@ static void filter_reset (GMimeFilter *filter);
static GMimeFilterClass *parent_class = NULL; static GMimeFilterClass *parent_class = NULL;
static void static void
notmuch_filter_discard_uuencode_class_init (NotmuchFilterDiscardUuencodeClass *klass) notmuch_filter_discard_non_term_class_init (NotmuchFilterDiscardNonTermClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass); GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass);
parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER); parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER);
object_class->finalize = notmuch_filter_discard_uuencode_finalize; object_class->finalize = notmuch_filter_discard_non_term_finalize;
filter_class->copy = filter_copy; filter_class->copy = filter_copy;
filter_class->filter = filter_filter; filter_class->filter = filter_filter;
@ -94,7 +94,7 @@ notmuch_filter_discard_uuencode_class_init (NotmuchFilterDiscardUuencodeClass *k
} }
static void static void
notmuch_filter_discard_uuencode_finalize (GObject *object) notmuch_filter_discard_non_term_finalize (GObject *object)
{ {
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -103,14 +103,14 @@ static GMimeFilter *
filter_copy (GMimeFilter *gmime_filter) filter_copy (GMimeFilter *gmime_filter)
{ {
(void) gmime_filter; (void) gmime_filter;
return notmuch_filter_discard_uuencode_new (); return notmuch_filter_discard_non_term_new ();
} }
static void static void
filter_filter (GMimeFilter *gmime_filter, char *inbuf, size_t inlen, size_t prespace, filter_filter (GMimeFilter *gmime_filter, char *inbuf, size_t inlen, size_t prespace,
char **outbuf, size_t *outlen, size_t *outprespace) char **outbuf, size_t *outlen, size_t *outprespace)
{ {
NotmuchFilterDiscardUuencode *filter = (NotmuchFilterDiscardUuencode *) gmime_filter; NotmuchFilterDiscardNonTerm *filter = (NotmuchFilterDiscardNonTerm *) gmime_filter;
register const char *inptr = inbuf; register const char *inptr = inbuf;
const char *inend = inbuf + inlen; const char *inend = inbuf + inlen;
char *outptr; char *outptr;
@ -185,40 +185,40 @@ filter_complete (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace
static void static void
filter_reset (GMimeFilter *gmime_filter) filter_reset (GMimeFilter *gmime_filter)
{ {
NotmuchFilterDiscardUuencode *filter = (NotmuchFilterDiscardUuencode *) gmime_filter; NotmuchFilterDiscardNonTerm *filter = (NotmuchFilterDiscardNonTerm *) gmime_filter;
filter->state = 0; filter->state = 0;
} }
/** /**
* notmuch_filter_discard_uuencode_new: * notmuch_filter_discard_non_term_new:
* *
* Returns: a new #NotmuchFilterDiscardUuencode filter. * Returns: a new #NotmuchFilterDiscardNonTerm filter.
**/ **/
static GMimeFilter * static GMimeFilter *
notmuch_filter_discard_uuencode_new (void) notmuch_filter_discard_non_term_new (void)
{ {
static GType type = 0; static GType type = 0;
NotmuchFilterDiscardUuencode *filter; NotmuchFilterDiscardNonTerm *filter;
if (!type) { if (!type) {
static const GTypeInfo info = { static const GTypeInfo info = {
sizeof (NotmuchFilterDiscardUuencodeClass), sizeof (NotmuchFilterDiscardNonTermClass),
NULL, /* base_class_init */ NULL, /* base_class_init */
NULL, /* base_class_finalize */ NULL, /* base_class_finalize */
(GClassInitFunc) notmuch_filter_discard_uuencode_class_init, (GClassInitFunc) notmuch_filter_discard_non_term_class_init,
NULL, /* class_finalize */ NULL, /* class_finalize */
NULL, /* class_data */ NULL, /* class_data */
sizeof (NotmuchFilterDiscardUuencode), sizeof (NotmuchFilterDiscardNonTerm),
0, /* n_preallocs */ 0, /* n_preallocs */
NULL, /* instance_init */ NULL, /* instance_init */
NULL /* value_table */ NULL /* value_table */
}; };
type = g_type_register_static (GMIME_TYPE_FILTER, "NotmuchFilterDiscardUuencode", &info, (GTypeFlags) 0); type = g_type_register_static (GMIME_TYPE_FILTER, "NotmuchFilterDiscardNonTerm", &info, (GTypeFlags) 0);
} }
filter = (NotmuchFilterDiscardUuencode *) g_object_newv (type, 0, NULL); filter = (NotmuchFilterDiscardNonTerm *) g_object_newv (type, 0, NULL);
filter->state = 0; filter->state = 0;
return (GMimeFilter *) filter; return (GMimeFilter *) filter;
@ -306,7 +306,7 @@ _index_mime_part (notmuch_message_t *message,
GMimeObject *part) GMimeObject *part)
{ {
GMimeStream *stream, *filter; GMimeStream *stream, *filter;
GMimeFilter *discard_uuencode_filter; GMimeFilter *discard_non_term_filter;
GMimeDataWrapper *wrapper; GMimeDataWrapper *wrapper;
GByteArray *byte_array; GByteArray *byte_array;
GMimeContentDisposition *disposition; GMimeContentDisposition *disposition;
@ -396,10 +396,10 @@ _index_mime_part (notmuch_message_t *message,
g_mime_stream_mem_set_owner (GMIME_STREAM_MEM (stream), FALSE); g_mime_stream_mem_set_owner (GMIME_STREAM_MEM (stream), FALSE);
filter = g_mime_stream_filter_new (stream); filter = g_mime_stream_filter_new (stream);
discard_uuencode_filter = notmuch_filter_discard_uuencode_new (); discard_non_term_filter = notmuch_filter_discard_non_term_new ();
g_mime_stream_filter_add (GMIME_STREAM_FILTER (filter), g_mime_stream_filter_add (GMIME_STREAM_FILTER (filter),
discard_uuencode_filter); discard_non_term_filter);
charset = g_mime_object_get_content_type_parameter (part, "charset"); charset = g_mime_object_get_content_type_parameter (part, "charset");
if (charset) { if (charset) {
@ -421,7 +421,7 @@ _index_mime_part (notmuch_message_t *message,
g_object_unref (stream); g_object_unref (stream);
g_object_unref (filter); g_object_unref (filter);
g_object_unref (discard_uuencode_filter); g_object_unref (discard_non_term_filter);
g_byte_array_append (byte_array, (guint8 *) "\0", 1); g_byte_array_append (byte_array, (guint8 *) "\0", 1);
body = (char *) g_byte_array_free (byte_array, FALSE); body = (char *) g_byte_array_free (byte_array, FALSE);