/* * move a msg to another maildir, trying to maintain 'integrity', * ie. msg in 'new/' will go to new/, one in cur/ goes to cur/. be * super-paranoid here... */ gboolean mu_msg_move_to_maildir (MuMsg *self, const char *maildir, MuFlags flags, gboolean ignore_dups, GError **err) { char *newfullpath; char *targetmdir; g_return_val_if_fail (self, FALSE); g_return_val_if_fail (maildir, FALSE); /* i.e. "/inbox" */ targetmdir = get_target_mdir (self, maildir, err); if (!targetmdir) return FALSE; newfullpath = mu_maildir_move_message (mu_msg_get_path (self), targetmdir, flags, ignore_dups, err); g_free (targetmdir); /* update the message path and the flags; they may have * changed */ if (newfullpath) { mu_msg_cache_set_str (self->_cache, MU_MSG_FIELD_ID_PATH, newfullpath, TRUE); /* the cache will free the string */ mu_msg_cache_set_str (self->_cache, MU_MSG_FIELD_ID_MAILDIR, g_strdup(maildir), TRUE); /* the cache will free the string */ /* the contentflags haven't changed, so make sure they persist */ flags |= mu_msg_get_flags (self) & (MU_FLAG_HAS_ATTACH|MU_FLAG_ENCRYPTED|MU_FLAG_SIGNED); /* update the pseudo-flag as well */ if (!(flags & MU_FLAG_NEW) && (flags & MU_FLAG_SEEN)) flags &= ~MU_FLAG_UNREAD; else flags |= MU_FLAG_UNREAD; mu_msg_cache_set_num (self->_cache, MU_MSG_FIELD_ID_FLAGS, flags); } return newfullpath ? TRUE : FALSE; }
/* * move a msg to another maildir, trying to maintain 'integrity', * ie. msg in 'new/' will go to new/, one in cur/ goes to cur/. be * super-paranoid here... */ gboolean mu_msg_move_to_maildir (MuMsg *self, const char *maildir, MuFlags flags, gboolean ignore_dups, gboolean new_name, GError **err) { char *newfullpath; char *targetmdir; g_return_val_if_fail (self, FALSE); g_return_val_if_fail (maildir, FALSE); /* i.e. "/inbox" */ /* targetmdir is the full path to maildir, i.e., * /home/foo/Maildir/inbox */ targetmdir = get_target_mdir (self, maildir, err); if (!targetmdir) return FALSE; newfullpath = mu_maildir_move_message (mu_msg_get_path (self), targetmdir, flags, ignore_dups, new_name, err); /* update the message path and the flags; they may have * changed */ if (!newfullpath) { g_free (targetmdir); return FALSE; } /* clear the old backends */ mu_msg_doc_destroy (self->_doc); self->_doc = NULL; mu_msg_file_destroy (self->_file); /* and create a new one */ self->_file = mu_msg_file_new (newfullpath, maildir, err); g_free (targetmdir); return self->_file ? TRUE : FALSE; }