mirror of https://github.com/djcb/mu.git
* mu-msg: add mu_msg_file_move_to_maildir which uses a path rather than a
MuMsg (cfg mu_msg_move_to_maildir)
This commit is contained in:
parent
8722110864
commit
d203c26591
27
src/mu-msg.c
27
src/mu-msg.c
|
@ -34,7 +34,7 @@
|
||||||
#include "mu-util.h"
|
#include "mu-util.h"
|
||||||
#include "mu-str.h"
|
#include "mu-str.h"
|
||||||
|
|
||||||
|
#include "mu-maildir.h"
|
||||||
|
|
||||||
static MuMsg*
|
static MuMsg*
|
||||||
msg_new (void)
|
msg_new (void)
|
||||||
|
@ -707,7 +707,7 @@ get_maildir_type (const char *path)
|
||||||
|
|
||||||
char*
|
char*
|
||||||
get_new_fullpath (const char *oldpath, const char *targetmdir,
|
get_new_fullpath (const char *oldpath, const char *targetmdir,
|
||||||
MaildirType mtype)
|
MaildirType mtype, MuMsgFlags flags)
|
||||||
{
|
{
|
||||||
char *filename, *newfullpath;
|
char *filename, *newfullpath;
|
||||||
const char* mdirsub;
|
const char* mdirsub;
|
||||||
|
@ -731,8 +731,18 @@ get_new_fullpath (const char *oldpath, const char *targetmdir,
|
||||||
G_DIR_SEPARATOR,
|
G_DIR_SEPARATOR,
|
||||||
filename);
|
filename);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
|
|
||||||
|
/* if flags != MU_MSG_FLAG_UNKNOWN, we update the filename for
|
||||||
|
* the new flags; in case the NEW flag is set/unset, this can
|
||||||
|
* also influence the dir */
|
||||||
|
if (flags != MU_MSG_FLAG_NONE) {
|
||||||
|
gchar *tmp;
|
||||||
|
tmp = mu_maildir_get_path_from_flags (newfullpath, flags);
|
||||||
|
newfullpath = tmp;
|
||||||
|
g_free (tmp);
|
||||||
|
}
|
||||||
|
|
||||||
return newfullpath;
|
return newfullpath;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -782,7 +792,7 @@ msg_move (const char* oldpath, const char *newfullpath, GError **err)
|
||||||
*/
|
*/
|
||||||
gchar*
|
gchar*
|
||||||
mu_msg_file_move_to_maildir (const char* oldpath, const char* targetmdir,
|
mu_msg_file_move_to_maildir (const char* oldpath, const char* targetmdir,
|
||||||
GError **err)
|
MuMsgFlags flags, GError **err)
|
||||||
{
|
{
|
||||||
MaildirType mtype;
|
MaildirType mtype;
|
||||||
char *newfullpath;
|
char *newfullpath;
|
||||||
|
@ -816,8 +826,8 @@ mu_msg_file_move_to_maildir (const char* oldpath, const char* targetmdir,
|
||||||
"target is not a read-writable dir: '%s'", targetmdir);
|
"target is not a read-writable dir: '%s'", targetmdir);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
newfullpath = get_new_fullpath (oldpath, targetmdir, mtype);
|
newfullpath = get_new_fullpath (oldpath, targetmdir, mtype, flags);
|
||||||
if (!newfullpath) {
|
if (!newfullpath) {
|
||||||
g_set_error (err, 0, MU_ERROR_FILE,
|
g_set_error (err, 0, MU_ERROR_FILE,
|
||||||
"failed to determine target full path");
|
"failed to determine target full path");
|
||||||
|
@ -841,7 +851,8 @@ mu_msg_file_move_to_maildir (const char* oldpath, const char* targetmdir,
|
||||||
* super-paranoid here...
|
* super-paranoid here...
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
mu_msg_move_to_maildir (MuMsg *self, const char* targetmdir, GError **err)
|
mu_msg_move_to_maildir (MuMsg *self, const char* targetmdir,
|
||||||
|
MuMsgFlags flags, GError **err)
|
||||||
{
|
{
|
||||||
char *newfullpath;
|
char *newfullpath;
|
||||||
|
|
||||||
|
@ -849,7 +860,7 @@ mu_msg_move_to_maildir (MuMsg *self, const char* targetmdir, GError **err)
|
||||||
g_return_val_if_fail (targetmdir, FALSE);
|
g_return_val_if_fail (targetmdir, FALSE);
|
||||||
|
|
||||||
newfullpath = mu_msg_file_move_to_maildir (mu_msg_get_path (self),
|
newfullpath = mu_msg_file_move_to_maildir (mu_msg_get_path (self),
|
||||||
targetmdir, err);
|
targetmdir, flags, err);
|
||||||
if (newfullpath) /* update our path to new one... */
|
if (newfullpath) /* update our path to new one... */
|
||||||
mu_msg_cache_set_str (self->_cache, MU_MSG_FIELD_ID_PATH, newfullpath,
|
mu_msg_cache_set_str (self->_cache, MU_MSG_FIELD_ID_PATH, newfullpath,
|
||||||
TRUE); /* the cache will free the string */
|
TRUE); /* the cache will free the string */
|
||||||
|
|
|
@ -388,17 +388,16 @@ char* mu_msg_to_sexp (MuMsg *msg, gboolean dbonly);
|
||||||
* 'cur' or 'new' part. mu_msg_move_to_maildir will make sure that the
|
* 'cur' or 'new' part. mu_msg_move_to_maildir will make sure that the
|
||||||
* copy is from new/ to new/ and cur/ to cur/. Also note that the target
|
* copy is from new/ to new/ and cur/ to cur/. Also note that the target
|
||||||
* maildir must be on the same filesystem. *
|
* maildir must be on the same filesystem. *
|
||||||
|
* @param flags to set for the target (influences the filename)
|
||||||
* @param err (may be NULL) may contain error information; note if the
|
* @param err (may be NULL) may contain error information; note if the
|
||||||
* function return FALSE, err is not set for all error condition
|
* function return FALSE, err is not set for all error condition
|
||||||
* (ie. not for parameter errors)
|
* (ie. not for parameter errors)
|
||||||
* @return TRUE if it worked, FALSE otherwise (mu_msg_move_to_maildir) or the full path name of the target file (g_free) for mu_msg_file_move_to_maildir
|
* @return TRUE if it worked, FALSE otherwise (mu_msg_move_to_maildir) or the full path name of the target file (g_free) for mu_msg_file_move_to_maildir
|
||||||
*/
|
*/
|
||||||
gboolean mu_msg_move_to_maildir (MuMsg *msg, const char* targetmdir,
|
gboolean mu_msg_move_to_maildir (MuMsg *msg, const char* targetmdir,
|
||||||
GError **err);
|
MuMsgFlags flags, GError **err);
|
||||||
char* mu_msg_file_move_to_maildir (const char *msgpath, const char* targetmdir,
|
char* mu_msg_file_move_to_maildir (const char *msgpath, const char* targetmdir,
|
||||||
GError **err);
|
MuMsgFlags flags, GError **err);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum _MuMsgContactType { /* Reply-To:? */
|
enum _MuMsgContactType { /* Reply-To:? */
|
||||||
MU_MSG_CONTACT_TYPE_TO = 0,
|
MU_MSG_CONTACT_TYPE_TO = 0,
|
||||||
|
|
Loading…
Reference in New Issue