Initialize the gmime for upstream
[platform/upstream/gmime.git] / gmime / gmime-filter-best.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*  GMime
3  *  Copyright (C) 2000-2012 Jeffrey Stedfast
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Lesser General Public License
7  *  as published by the Free Software Foundation; either version 2.1
8  *  of the License, or (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *  Lesser General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Lesser General Public
16  *  License along with this library; if not, write to the Free
17  *  Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
18  *  02110-1301, USA.
19  */
20
21
22 #ifndef __GMIME_FILTER_BEST_H__
23 #define __GMIME_FILTER_BEST_H__
24
25 #include <gmime/gmime-encodings.h>
26 #include <gmime/gmime-filter.h>
27 #include <gmime/gmime-charset.h>
28 #include <gmime/gmime-utils.h>
29
30 G_BEGIN_DECLS
31
32 #define GMIME_TYPE_FILTER_BEST            (g_mime_filter_best_get_type ())
33 #define GMIME_FILTER_BEST(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_FILTER_BEST, GMimeFilterBest))
34 #define GMIME_FILTER_BEST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_FILTER_BEST, GMimeFilterBestClass))
35 #define GMIME_IS_FILTER_BEST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_FILTER_BEST))
36 #define GMIME_IS_FILTER_BEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_FILTER_BEST))
37 #define GMIME_FILTER_BEST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_FILTER_BEST, GMimeFilterBestClass))
38
39 typedef struct _GMimeFilterBest GMimeFilterBest;
40 typedef struct _GMimeFilterBestClass GMimeFilterBestClass;
41
42 /**
43  * GMimeFilterBestFlags:
44  * @GMIME_FILTER_BEST_CHARSET: Enable best-charset detection.
45  * @GMIME_FILTER_BEST_ENCODING: Enable best-encoding detection.
46  *
47  * Bit flags to enable charset and/or encoding scanning to make
48  * educated guesses as to what the best charset and/or encodings to
49  * use for the content passed through the filter.
50  **/
51 typedef enum {
52         GMIME_FILTER_BEST_CHARSET  = (1 << 0),
53         GMIME_FILTER_BEST_ENCODING = (1 << 1)
54 } GMimeFilterBestFlags;
55
56
57 /**
58  * GMimeFilterBest:
59  * @parent_object: parent #GMimeFilter
60  * @flags: #GMimeFilterBestFlags
61  * @charset: #GMimeCharset state
62  * @count0: count of nul-bytes passed through the filter
63  * @count8: count of 8bit bytes passed through the filter
64  * @total: total number of bytes passed through the filter
65  * @maxline: the length of the longest line passed through the filter
66  * @linelen: current line length
67  * @frombuf: buffer for checking From_ lines
68  * @fromlen: length of bytes in @frombuf
69  * @hadfrom: %TRUE if any line started with "From "
70  * @startline: start line state
71  * @midline: mid-line state
72  *
73  * A filter for calculating the best encoding and/or charset to encode
74  * the data passed through it.
75  **/
76 struct _GMimeFilterBest {
77         GMimeFilter parent_object;
78         
79         GMimeFilterBestFlags flags;
80         
81         /* for best charset detection */
82         GMimeCharset charset;
83         
84         /* for best encoding detection */
85         unsigned int count0;      /* count of null bytes */
86         unsigned int count8;      /* count of 8bit bytes */
87         unsigned int total;       /* total octets */
88         
89         unsigned int maxline;     /* longest line length */
90         unsigned int linelen;     /* current line length */
91         
92         unsigned char frombuf[6];
93         unsigned int fromlen : 4;
94         unsigned int hadfrom : 1;
95         
96         unsigned int startline : 1;
97         unsigned int midline : 1;
98 };
99
100 struct _GMimeFilterBestClass {
101         GMimeFilterClass parent_class;
102         
103 };
104
105
106 GType g_mime_filter_best_get_type (void);
107
108 GMimeFilter *g_mime_filter_best_new (GMimeFilterBestFlags flags);
109
110 const char *g_mime_filter_best_charset (GMimeFilterBest *best);
111
112 GMimeContentEncoding g_mime_filter_best_encoding (GMimeFilterBest *best, GMimeEncodingConstraint constraint);
113
114 G_END_DECLS
115
116 #endif /* __GMIME_FILTER_BEST_H__ */