summaryrefslogtreecommitdiff
path: root/lib/mu-msg-file.h
blob: e26c4a7727ec570352c5f82d8e8733b39c27cde8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/

/*
** Copyright (C) 2012-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
** Free Software Foundation; either version 3, or (at your option) any
** later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation,
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/

#ifndef __MU_MSG_FILE_H__
#define __MU_MSG_FILE_H__

struct _MuMsgFile;
typedef struct _MuMsgFile MuMsgFile;

/**
 * create a new message from a file
 *
 * @param path full path to the message
 * @param mdir
 * @param err error to receive (when function returns NULL), or NULL
 *
 * @return a new MuMsg, or NULL in case of error
 */
MuMsgFile *mu_msg_file_new (const char *path,
			    const char* mdir, GError **err)
                            G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;

/**
 * destroy a MuMsgFile object
 *
 * @param self object to destroy, or NULL
 */
void mu_msg_file_destroy (MuMsgFile *self);



/**
 * get a specific header
 *
 * @param self a MuMsgFile instance
 * @param header a header (e.g. 'X-Mailer' or 'List-Id')
 *
 * @return the value of the header or NULL if not found; free with g_free
 */
char* mu_msg_file_get_header (MuMsgFile *self, const char *header);


/**
 * get a string value for this message
 *
 * @param self a valid MuMsgFile
 * @param msfid the message field id to get (must be of type string)
 * @param do_free receives TRUE or FALSE, conveying if this string
 * should be owned & freed (TRUE) or not by caller. In case 'FALSE',
 * this function should be treated as if it were returning a const
 * char*, and note that in that case the string is only valid as long
 * as the MuMsgFile is alive, ie. before mu_msg_file_destroy
 *
 * @return a string, or NULL
 */
char* mu_msg_file_get_str_field (MuMsgFile *self,
				 MuMsgFieldId msfid,
				 gboolean *do_free)
	                         G_GNUC_WARN_UNUSED_RESULT;


/**
 * get a string-list value for this message
 *
 * @param self a valid MuMsgFile
 * @param msfid the message field id to get (must be of type string-list)
 *
 * @return a GSList*, or NULL; free with mu_str_free_list
 */
GSList* mu_msg_file_get_str_list_field (MuMsgFile *self, MuMsgFieldId msfid)
					G_GNUC_WARN_UNUSED_RESULT;



/**
 * get a numeric value for this message -- the return value should be
 * cast into the actual type, e.g., time_t, MuMsgPrio etc.
 *
 * @param self a valid MuMsgFile
 * @param msfid the message field id to get (must be string-based one)
 *
 * @return the numeric value, or -1 in case of error
 */
gint64 mu_msg_file_get_num_field (MuMsgFile *self, MuMsgFieldId mfid);


#endif /*__MU_MSG_FILE_H__*/