2020-11-28 09:15:49 +01:00
|
|
|
/*
|
2022-02-13 13:32:10 +01:00
|
|
|
** Copyright (C) 2010-2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
2009-11-25 21:55:06 +01:00
|
|
|
**
|
|
|
|
** 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 of the License, or
|
|
|
|
** (at your option) any later version.
|
2011-09-03 09:48:36 +02:00
|
|
|
**
|
2009-11-25 21:55:06 +01:00
|
|
|
** 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.
|
2011-09-03 09:48:36 +02:00
|
|
|
**
|
2009-11-25 21:55:06 +01:00
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program; if not, write to the Free Software Foundation,
|
2011-09-03 09:48:36 +02:00
|
|
|
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
**
|
2009-11-25 21:55:06 +01:00
|
|
|
*/
|
|
|
|
|
2020-11-28 09:15:49 +01:00
|
|
|
#ifndef MU_MSG_HH__
|
|
|
|
#define MU_MSG_HH__
|
2009-11-25 21:55:06 +01:00
|
|
|
|
2022-02-16 21:06:00 +01:00
|
|
|
#include <utils/mu-result.hh>
|
|
|
|
|
2022-03-20 13:12:41 +01:00
|
|
|
#include <message/mu-message.hh>
|
2022-02-16 21:06:00 +01:00
|
|
|
|
2019-12-16 20:44:35 +01:00
|
|
|
#include <utils/mu-util.h>
|
2020-11-28 09:15:49 +01:00
|
|
|
#include <utils/mu-utils.hh>
|
|
|
|
#include <utils/mu-option.hh>
|
|
|
|
#include <utils/mu-sexp.hh>
|
2009-11-25 21:55:06 +01:00
|
|
|
|
2020-11-28 09:15:49 +01:00
|
|
|
namespace Mu {
|
2010-08-24 23:57:16 +02:00
|
|
|
|
2020-11-28 09:15:49 +01:00
|
|
|
struct MuMsg;
|
2010-08-24 23:57:16 +02:00
|
|
|
|
2012-07-18 15:22:10 +02:00
|
|
|
/* options for various functions */
|
2020-11-28 09:15:49 +01:00
|
|
|
enum MuMsgOptions {
|
2021-10-20 11:18:15 +02:00
|
|
|
MU_MSG_OPTION_NONE = 0,
|
|
|
|
/* 1 << 0 is still free! */
|
2012-07-18 15:22:10 +02:00
|
|
|
|
|
|
|
/* for -> sexp conversion */
|
2021-10-20 11:18:15 +02:00
|
|
|
MU_MSG_OPTION_HEADERS_ONLY = 1 << 1,
|
|
|
|
MU_MSG_OPTION_EXTRACT_IMAGES = 1 << 2,
|
2012-07-18 15:22:10 +02:00
|
|
|
|
|
|
|
/* below options are for checking signatures; only effective
|
|
|
|
* if mu was built with crypto support */
|
2021-10-20 11:18:15 +02:00
|
|
|
MU_MSG_OPTION_VERIFY = 1 << 4,
|
|
|
|
MU_MSG_OPTION_AUTO_RETRIEVE = 1 << 5,
|
|
|
|
MU_MSG_OPTION_USE_AGENT = 1 << 6,
|
2012-08-10 08:39:24 +02:00
|
|
|
/* MU_MSG_OPTION_USE_PKCS7 = 1 << 7, /\* gpg is the default *\/ */
|
2012-08-01 16:02:43 +02:00
|
|
|
|
2012-09-13 21:57:04 +02:00
|
|
|
/* get password from console if needed */
|
2021-10-20 11:18:15 +02:00
|
|
|
MU_MSG_OPTION_CONSOLE_PASSWORD = 1 << 7,
|
2012-09-13 21:57:04 +02:00
|
|
|
|
2021-10-20 11:18:15 +02:00
|
|
|
MU_MSG_OPTION_DECRYPT = 1 << 8,
|
2012-08-01 16:02:43 +02:00
|
|
|
|
|
|
|
/* misc */
|
2021-10-20 11:18:15 +02:00
|
|
|
MU_MSG_OPTION_OVERWRITE = 1 << 9,
|
|
|
|
MU_MSG_OPTION_USE_EXISTING = 1 << 10,
|
2012-08-01 16:02:43 +02:00
|
|
|
|
|
|
|
/* recurse into submessages */
|
2021-10-20 11:18:15 +02:00
|
|
|
MU_MSG_OPTION_RECURSE_RFC822 = 1 << 11
|
2020-11-28 09:15:49 +01:00
|
|
|
};
|
|
|
|
MU_ENABLE_BITOPS(MuMsgOptions);
|
2012-07-18 15:22:10 +02:00
|
|
|
|
2010-08-24 23:57:16 +02:00
|
|
|
/**
|
|
|
|
* create a new MuMsg* instance which parses a message and provides
|
2011-05-15 09:40:58 +02:00
|
|
|
* read access to its properties; call mu_msg_unref when done with it.
|
2010-08-24 23:57:16 +02:00
|
|
|
*
|
|
|
|
* @param path full path to an email message file
|
|
|
|
* @param mdir the maildir for this message; ie, if the path is
|
|
|
|
* ~/Maildir/foo/bar/cur/msg, the maildir would be foo/bar; you can
|
|
|
|
* pass NULL for this parameter, in which case some maildir-specific
|
|
|
|
* information is not available.
|
2011-05-19 18:57:26 +02:00
|
|
|
* @param err receive error information (MU_ERROR_FILE or
|
|
|
|
* MU_ERROR_GMIME), or NULL. There will only be err info if the
|
|
|
|
* function returns NULL
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-01-09 17:54:14 +01:00
|
|
|
* @return a new MuMsg instance or NULL in case of error; call
|
|
|
|
* mu_msg_unref when done with this message
|
2010-08-24 23:57:16 +02:00
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
MuMsg* mu_msg_new_from_file(const char* filepath,
|
2022-03-03 23:04:30 +01:00
|
|
|
const char* maildir,
|
|
|
|
GError** err) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
2011-01-09 17:54:14 +01:00
|
|
|
|
2011-05-15 10:06:55 +02:00
|
|
|
/**
|
|
|
|
* create a new MuMsg* instance based on a Xapian::Document
|
|
|
|
*
|
2011-09-03 09:48:36 +02:00
|
|
|
* @param store a MuStore ptr
|
2011-05-15 10:06:55 +02:00
|
|
|
* @param doc a ptr to a Xapian::Document (but cast to XapianDocument,
|
2011-06-18 17:48:59 +02:00
|
|
|
* because this is C not C++). MuMsg takes _ownership_ of this pointer;
|
|
|
|
* don't touch it afterwards
|
2011-05-15 10:06:55 +02:00
|
|
|
* @param err receive error information, or NULL. There
|
|
|
|
* will only be err info if the function returns NULL
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-05-15 10:06:55 +02:00
|
|
|
* @return a new MuMsg instance or NULL in case of error; call
|
|
|
|
* mu_msg_unref when done with this message
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
MuMsg* mu_msg_new_from_doc(XapianDocument* doc,
|
2022-03-03 23:04:30 +01:00
|
|
|
GError** err) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
2011-05-15 10:06:55 +02:00
|
|
|
|
2012-07-16 11:55:54 +02:00
|
|
|
/**
|
|
|
|
* if we don't have a message file yet (because this message is
|
|
|
|
* database-backed), load it.
|
|
|
|
*
|
|
|
|
* @param msg a MuMsg
|
|
|
|
* @param err receives error information
|
|
|
|
*
|
2019-11-06 16:13:39 +01:00
|
|
|
* @return TRUE if this succeeded, FALSE in case of error
|
2012-07-16 11:55:54 +02:00
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
gboolean mu_msg_load_msg_file(MuMsg* msg, GError** err);
|
2012-07-16 11:55:54 +02:00
|
|
|
|
2012-01-11 23:20:14 +01:00
|
|
|
/**
|
|
|
|
* close the file-backend, if any; this function is for the use case
|
|
|
|
* where you have a large amount of messages where you need some
|
|
|
|
* file-backed field (body or attachments). If you don't close the
|
|
|
|
* file-backend after retrieving the desired field, you'd quickly run
|
|
|
|
* out of file descriptors. If this message does not have a
|
|
|
|
* file-backend, do nothing.
|
|
|
|
*
|
|
|
|
* @param msg a message object
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
void mu_msg_unload_msg_file(MuMsg* msg);
|
2012-07-16 11:55:54 +02:00
|
|
|
|
2010-08-24 23:57:16 +02:00
|
|
|
/**
|
2011-01-09 17:54:14 +01:00
|
|
|
* increase the reference count for this message
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-01-09 17:54:14 +01:00
|
|
|
* @param msg a message
|
|
|
|
*
|
|
|
|
* @return the message with its reference count increased, or NULL in
|
|
|
|
* case of error.
|
2010-08-24 23:57:16 +02:00
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
MuMsg* mu_msg_ref(MuMsg* msg);
|
2011-01-09 17:54:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* decrease the reference count for this message. if the reference
|
|
|
|
* count reaches 0, the message will be destroyed.
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-01-09 17:54:14 +01:00
|
|
|
* @param msg a message
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
void mu_msg_unref(MuMsg* msg);
|
2011-01-09 17:54:14 +01:00
|
|
|
|
2011-05-14 17:07:51 +02:00
|
|
|
/**
|
|
|
|
* cache the values from the backend (file or db), so we don't the
|
|
|
|
* backend anymore
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-05-14 17:07:51 +02:00
|
|
|
* @param self a message
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
void mu_msg_cache_values(MuMsg* self);
|
2011-05-14 17:07:51 +02:00
|
|
|
|
2010-08-24 23:57:16 +02:00
|
|
|
/**
|
|
|
|
* get the plain text body of this message
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2012-08-09 08:38:22 +02:00
|
|
|
* @param opts options for getting the body
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2010-08-24 23:57:16 +02:00
|
|
|
* @return the plain text body or NULL in case of error or if there is no
|
|
|
|
* such body. the returned string should *not* be modified or freed.
|
|
|
|
* The returned data is in UTF8 or NULL.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_body_text(MuMsg* msg, MuMsgOptions opts);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
2016-12-18 17:16:02 +01:00
|
|
|
/**
|
|
|
|
* get the content type parameters for the text body part
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
|
|
|
* @param opts options for getting the body
|
|
|
|
*
|
|
|
|
* @return the value of the requested body part content type parameter, or
|
|
|
|
* NULL in case of error or if there is no such body. the returned string
|
|
|
|
* should *not* be modified or freed. The returned data is in UTF8 or NULL.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const GSList* mu_msg_get_body_text_content_type_parameters(MuMsg* self, MuMsgOptions opts);
|
2016-12-18 17:16:02 +01:00
|
|
|
|
2010-08-24 23:57:16 +02:00
|
|
|
/**
|
|
|
|
* get the html body of this message
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2012-08-09 08:38:22 +02:00
|
|
|
* @param opts options for getting the body
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2010-08-24 23:57:16 +02:00
|
|
|
* @return the html body or NULL in case of error or if there is no
|
|
|
|
* such body. the returned string should *not* be modified or freed.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_body_html(MuMsg* msgMu, MuMsgOptions opts);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the sender (From:) of this message
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
|
|
|
* @return the sender of this Message or NULL in case of error or if there
|
2010-08-24 23:57:16 +02:00
|
|
|
* is no sender. the returned string should *not* be modified or freed.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_from(MuMsg* msg);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the recipients (To:) of this message
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
|
|
|
* @return the sender of this Message or NULL in case of error or if there
|
2010-08-24 23:57:16 +02:00
|
|
|
* are no recipients. the returned string should *not* be modified or freed.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_to(MuMsg* msg);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the carbon-copy recipients (Cc:) of this message
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
|
|
|
* @return the Cc: recipients of this Message or NULL in case of error or if
|
|
|
|
* there are no such recipients. the returned string should *not* be modified
|
2010-08-24 23:57:16 +02:00
|
|
|
* or freed.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_cc(MuMsg* msg);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
2011-05-01 17:31:00 +02:00
|
|
|
/**
|
|
|
|
* get the blind carbon-copy recipients (Bcc:) of this message; this
|
|
|
|
* field usually only appears in outgoing messages
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-05-01 17:31:00 +02:00
|
|
|
* @return the Bcc: recipients of this Message or NULL in case of
|
|
|
|
* error or if there are no such recipients. the returned string
|
|
|
|
* should *not* be modified or freed.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_bcc(MuMsg* msg);
|
2011-05-01 17:31:00 +02:00
|
|
|
|
2010-08-24 23:57:16 +02:00
|
|
|
/**
|
|
|
|
* get the file system path of this message
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
|
|
|
* @return the path of this Message or NULL in case of error.
|
2010-08-24 23:57:16 +02:00
|
|
|
* the returned string should *not* be modified or freed.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_path(MuMsg* msg);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the maildir this message lives in; ie, if the path is
|
|
|
|
* ~/Maildir/foo/bar/cur/msg, the maildir would be foo/bar
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2010-08-24 23:57:16 +02:00
|
|
|
* @return the maildir requested or NULL in case of error. The returned
|
|
|
|
* string should *not* be modified or freed.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_maildir(MuMsg* msg);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the subject of this message
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
|
|
|
* @return the subject of this Message or NULL in case of error or if there
|
2010-08-24 23:57:16 +02:00
|
|
|
* is no subject. the returned string should *not* be modified or freed.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_subject(MuMsg* msg);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the Message-Id of this message
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2013-04-09 20:20:25 +02:00
|
|
|
* @return the Message-Id of this message (without the enclosing <>),
|
|
|
|
* or a fake message-id for messages that don't have them, or NULL in
|
|
|
|
* case of error.
|
2010-08-24 23:57:16 +02:00
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_msgid(MuMsg* msg);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
2012-12-20 22:35:53 +01:00
|
|
|
/**
|
|
|
|
* get the mailing list for a message, i.e. the mailing-list
|
|
|
|
* identifier in the List-Id header.
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
|
|
|
*
|
|
|
|
* @return the mailing list id for this message (without the enclosing <>)
|
|
|
|
* or NULL in case of error or if there is none. the returned string
|
|
|
|
* should *not* be modified or freed.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_mailing_list(MuMsg* msg);
|
2012-12-20 22:35:53 +01:00
|
|
|
|
2010-08-24 23:57:16 +02:00
|
|
|
/**
|
|
|
|
* get the message date/time (the Date: field) as time_t, using UTC
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
|
|
|
* @return message date/time or 0 in case of error or if there
|
2010-08-24 23:57:16 +02:00
|
|
|
* is no such header.
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
time_t mu_msg_get_date(MuMsg* msg);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the flags for this message
|
|
|
|
*
|
|
|
|
* @param msg valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2022-03-20 13:12:41 +01:00
|
|
|
* @return the file/content flags as logically OR'd #Mu::Flags.
|
2022-02-16 21:06:00 +01:00
|
|
|
* Non-standard flags are ignored.
|
2010-08-24 23:57:16 +02:00
|
|
|
*/
|
2022-03-20 13:12:41 +01:00
|
|
|
Flags mu_msg_get_flags(MuMsg* msg);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the file size in bytes of this message
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
|
|
|
* @return the filesize
|
2010-08-24 23:57:16 +02:00
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
size_t mu_msg_get_size(MuMsg* msg);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get some field value as string
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2010-08-24 23:57:16 +02:00
|
|
|
* @param msg a valid MuMsg instance
|
|
|
|
* @param field the field to retrieve; it must be a string-typed field
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2010-08-24 23:57:16 +02:00
|
|
|
* @return a string that should not be freed
|
|
|
|
*/
|
2022-03-20 13:12:41 +01:00
|
|
|
const char* mu_msg_get_field_string(MuMsg* msg, Field::Id mfid);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
2011-06-15 22:51:16 +02:00
|
|
|
/**
|
|
|
|
* get some field value as string-list
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-06-15 22:51:16 +02:00
|
|
|
* @param msg a valid MuMsg instance
|
|
|
|
* @param field the field to retrieve; it must be a string-list-typed field
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-06-15 22:51:16 +02:00
|
|
|
* @return a list that should not be freed
|
|
|
|
*/
|
2022-03-20 13:12:41 +01:00
|
|
|
const GSList* mu_msg_get_field_string_list(MuMsg* self, Field::Id mfid);
|
2011-06-15 22:51:16 +02:00
|
|
|
|
2010-08-24 23:57:16 +02:00
|
|
|
/**
|
|
|
|
* get some field value as string
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2010-08-24 23:57:16 +02:00
|
|
|
* @param msg a valid MuMsg instance
|
|
|
|
* @param field the field to retrieve; it must be a numeric field
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2010-08-24 23:57:16 +02:00
|
|
|
* @return a string that should not be freed
|
|
|
|
*/
|
2022-03-20 13:12:41 +01:00
|
|
|
gint64 mu_msg_get_field_numeric(MuMsg* msg, Field::Id mfid);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
|
|
|
/**
|
2022-02-13 13:32:10 +01:00
|
|
|
* get the message priority for this message. The X-Priority, X-MSMailPriority,
|
|
|
|
* Importance and Precedence header are checked, in that order. if no known or
|
|
|
|
* explicit priority is set, MessagePriority::Id::Normal is assumed
|
2010-08-24 23:57:16 +02:00
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2022-02-13 13:32:10 +01:00
|
|
|
* @return the message priority
|
2010-08-24 23:57:16 +02:00
|
|
|
*/
|
2022-03-20 13:12:41 +01:00
|
|
|
Priority mu_msg_get_prio(MuMsg* msg);
|
2010-08-24 23:57:16 +02:00
|
|
|
|
|
|
|
/**
|
2011-09-03 09:48:36 +02:00
|
|
|
* get the timestamp (mtime) for the file containing this message
|
2010-08-24 23:57:16 +02:00
|
|
|
*
|
|
|
|
* @param msg a valid MuMsg* instance
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2010-08-24 23:57:16 +02:00
|
|
|
* @return the timestamp or 0 in case of error
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
time_t mu_msg_get_timestamp(MuMsg* msg);
|
2011-01-10 23:45:03 +01:00
|
|
|
|
2011-05-19 21:25:27 +02:00
|
|
|
/**
|
|
|
|
* get a specific header from the message. This value will _not_ be
|
|
|
|
* cached
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-05-19 21:25:27 +02:00
|
|
|
* @param self a MuMsg instance
|
|
|
|
* @param header a specific header (like 'X-Mailer' or 'Organization')
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-05-19 21:25:27 +02:00
|
|
|
* @return a header string which is valid as long as this MuMsg is
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_msg_get_header(MuMsg* self, const char* header);
|
2011-05-19 21:25:27 +02:00
|
|
|
|
2011-05-01 14:01:03 +02:00
|
|
|
/**
|
2012-12-25 15:44:26 +01:00
|
|
|
* get the list of references (consisting of both the References and
|
|
|
|
* In-Reply-To fields), with the oldest first and the direct parent as
|
|
|
|
* the last one. Note, any reference (message-id) will appear at most
|
|
|
|
* once, duplicates are filtered out.
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-04-30 12:50:56 +02:00
|
|
|
* @param msg a valid MuMsg
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-06-15 23:26:30 +02:00
|
|
|
* @return a list with the references for this msg. Don't modify/free
|
2011-04-30 12:50:56 +02:00
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const GSList* mu_msg_get_references(MuMsg* msg);
|
2011-06-15 23:26:30 +02:00
|
|
|
|
|
|
|
/**
|
2011-06-13 22:04:56 +02:00
|
|
|
* get the list of tags (ie., X-Label)
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-06-15 23:26:30 +02:00
|
|
|
* @param msg a valid MuMsg
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-06-15 23:26:30 +02:00
|
|
|
* @return a list with the tags for this msg. Don't modify/free
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const GSList* mu_msg_get_tags(MuMsg* self);
|
2011-05-14 17:14:24 +02:00
|
|
|
|
2011-07-02 10:27:08 +02:00
|
|
|
/**
|
|
|
|
* compare two messages for sorting
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-07-02 10:27:08 +02:00
|
|
|
* @param m1 a message
|
|
|
|
* @param m2 another message
|
|
|
|
* @param mfid the message to use for the comparison
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-07-02 10:27:08 +02:00
|
|
|
* @return negative if m1 is smaller, positive if m1 is smaller, 0 if
|
|
|
|
* they are equal
|
|
|
|
*/
|
2022-03-20 13:12:41 +01:00
|
|
|
int mu_msg_cmp(MuMsg* m1, MuMsg* m2, Field::Id mfid);
|
2011-07-02 10:27:08 +02:00
|
|
|
|
2011-08-03 22:03:58 +02:00
|
|
|
/**
|
2011-09-03 09:48:36 +02:00
|
|
|
* check whether there there's a readable file behind this message
|
|
|
|
*
|
2011-08-03 22:03:58 +02:00
|
|
|
* @param self a MuMsg*
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-08-03 22:03:58 +02:00
|
|
|
* @return TRUE if the message file is readable, FALSE otherwise
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
gboolean mu_msg_is_readable(MuMsg* self);
|
2011-08-03 22:03:58 +02:00
|
|
|
|
2011-07-25 07:19:58 +02:00
|
|
|
/**
|
2011-09-12 19:42:53 +02:00
|
|
|
* move a message to another maildir; note that this does _not_ update
|
|
|
|
* the database
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2011-07-25 07:19:58 +02:00
|
|
|
* @param msg a message with an existing file system path in an actual
|
|
|
|
* maildir
|
2022-02-16 21:06:00 +01:00
|
|
|
* @param root_maildir_path file system path for the root-maildir for this message
|
|
|
|
* e.g., /home/user/Maildir
|
|
|
|
* @param target_maildir the subdir where the message should go, relative to
|
2011-09-18 13:42:55 +02:00
|
|
|
* rootmaildir. e.g. "/archive"
|
2011-08-13 01:00:04 +02:00
|
|
|
* @param flags to set for the target (influences the filename, path)
|
2011-08-16 22:43:57 +02:00
|
|
|
* @param silently ignore the src=target case (return TRUE)
|
2013-05-25 18:27:54 +02:00
|
|
|
* @param new_name whether to create a new unique name, or keep the
|
|
|
|
* old one
|
2022-02-16 21:06:00 +01:00
|
|
|
* @param err receives error information
|
2017-01-14 12:09:17 +01:00
|
|
|
*
|
|
|
|
* @return TRUE if it worked, FALSE otherwise
|
|
|
|
*/
|
2022-02-16 21:06:00 +01:00
|
|
|
bool mu_msg_move_to_maildir(MuMsg* msg,
|
|
|
|
const std::string& root_maildir_path,
|
|
|
|
const std::string& target_maildir,
|
2022-03-20 13:12:41 +01:00
|
|
|
Flags flags,
|
2022-02-16 21:06:00 +01:00
|
|
|
bool ignore_dups,
|
|
|
|
bool new_name,
|
|
|
|
GError** err);
|
2022-03-03 23:04:30 +01:00
|
|
|
/**
|
2022-02-19 17:57:50 +01:00
|
|
|
* Get a sequence with contacts of the given type for this message.
|
2011-09-03 09:48:36 +02:00
|
|
|
*
|
2022-02-19 17:57:50 +01:00
|
|
|
* @param msg a valid MuMsg* instance
|
2022-03-19 17:38:30 +01:00
|
|
|
* @param field_id the contact field or none; if none get _all_ contact types.
|
2022-03-03 23:04:30 +01:00
|
|
|
*
|
2022-02-19 17:57:50 +01:00
|
|
|
* @return a sequence
|
2011-05-14 17:14:24 +02:00
|
|
|
*/
|
2022-03-20 13:12:41 +01:00
|
|
|
Mu::Contacts mu_msg_get_contacts (MuMsg *self,
|
2022-03-28 07:58:04 +02:00
|
|
|
Option<Field::Id> field_id={});
|
2019-12-16 20:44:35 +01:00
|
|
|
/**
|
|
|
|
* create a 'display contact' from an email header To/Cc/Bcc/From-type address
|
|
|
|
* ie., turn
|
|
|
|
* "Foo Bar" <foo@bar.com>
|
|
|
|
* into
|
|
|
|
* Foo Bar
|
|
|
|
* Note that this is based on some simple heuristics. Max length is 255 bytes.
|
|
|
|
*
|
|
|
|
* mu_str_display_contact_s returns a statically allocated
|
|
|
|
* buffer (ie, non-reentrant), while mu_str_display_contact
|
|
|
|
* returns a newly allocated string that you must free with g_free
|
|
|
|
* when done with it.
|
|
|
|
*
|
|
|
|
* @param str a 'contact str' (ie., what is in the To/Cc/Bcc/From
|
|
|
|
* fields), or NULL
|
|
|
|
*
|
|
|
|
* @return a newly allocated string with a display contact
|
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
const char* mu_str_display_contact_s(const char* str) G_GNUC_CONST;
|
|
|
|
char* mu_str_display_contact(const char* str) G_GNUC_WARN_UNUSED_RESULT;
|
2019-12-16 20:44:35 +01:00
|
|
|
|
2022-02-19 17:57:50 +01:00
|
|
|
|
|
|
|
|
2020-11-28 09:15:49 +01:00
|
|
|
struct QueryMatch;
|
2020-06-06 09:18:58 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* convert the msg to a Lisp symbolic expression (for further processing in
|
|
|
|
* e.g. emacs)
|
|
|
|
*
|
|
|
|
* @param msg a valid message
|
|
|
|
* @param docid the docid for this message, or 0
|
|
|
|
* @param opts, bitwise OR'ed;
|
|
|
|
* - MU_MSG_OPTION_HEADERS_ONLY: only include message fields which can be
|
|
|
|
* obtained from the database (this is much faster if the MuMsg is
|
|
|
|
* database-backed, so no file needs to be opened)
|
|
|
|
* - MU_MSG_OPTION_EXTRACT_IMAGES: extract image attachments as temporary
|
|
|
|
* files and include links to those in the sexp
|
|
|
|
* and for message parts:
|
2022-03-03 23:04:30 +01:00
|
|
|
* MU_MSG_OPTION_CHECK_SIGNATURES: check signatures
|
2020-06-06 09:18:58 +02:00
|
|
|
* MU_MSG_OPTION_AUTO_RETRIEVE_KEY: attempt to retrieve keys online
|
|
|
|
* MU_MSG_OPTION_USE_AGENT: attempt to use GPG-agent
|
|
|
|
* MU_MSG_OPTION_USE_PKCS7: attempt to use PKCS (instead of gpg)
|
|
|
|
*
|
2021-01-29 21:39:21 +01:00
|
|
|
* @return a Mu::Sexp or a Mu::Sexp::List representing the message.
|
2020-06-06 09:18:58 +02:00
|
|
|
*/
|
2021-10-20 11:18:15 +02:00
|
|
|
Mu::Sexp::List msg_to_sexp_list(MuMsg* msg, unsigned docid, MuMsgOptions ops);
|
|
|
|
Mu::Sexp msg_to_sexp(MuMsg* msg, unsigned docid, MuMsgOptions ops);
|
|
|
|
} // namespace Mu
|
2020-06-06 09:18:58 +02:00
|
|
|
|
2020-11-28 09:15:49 +01:00
|
|
|
#endif /*MU_MSG_HH__*/
|