* lib: make renaming messages upon moving them optional

This commit is contained in:
djcb
2013-05-25 19:27:54 +03:00
parent 6e9390d5c2
commit 7cb3bb9e36
4 changed files with 34 additions and 26 deletions

View File

@ -766,9 +766,9 @@ get_new_basename (void)
char*
mu_maildir_get_new_path (const char *oldpath, const char *new_mdir,
MuFlags newflags)
MuFlags newflags, gboolean new_name)
{
char *mfile, *mdir, *custom_flags, *newpath;/**cur;q*/
char *mfile, *mdir, *custom_flags, *newpath;
g_return_val_if_fail (oldpath, NULL);
@ -779,21 +779,23 @@ mu_maildir_get_new_path (const char *oldpath, const char *new_mdir,
if (!mdir)
return NULL;
/* determine the name of the mailfile, stripped of its flags, as well
* as any custom (non-standard) flags */
/* /\* mfile = g_path_get_basename (oldpath); *\/ */
/* for (cur = &mfile[strlen(mfile)-1]; cur > mfile; --cur) { */
/* if ((*cur == ':' || *cur == '!') && */
/* (cur[1] == '2' && cur[2] == ',')) { */
/* /\* get the custom flags (if any) *\/ */
/* custom_flags = mu_flags_custom_from_str (cur + 3); */
/* cur[0] = '\0'; /\* strip the flags *\/ */
/* break; */
/* } */
/* } */
mfile = get_new_basename ();
if (new_name)
mfile = get_new_basename ();
else {
/* determine the name of the mailfile, stripped of its flags, as well
* as any custom (non-standard) flags */
char *cur;
mfile = g_path_get_basename (oldpath);
for (cur = &mfile[strlen(mfile)-1]; cur > mfile; --cur) {
if ((*cur == ':' || *cur == '!') &&
(cur[1] == '2' && cur[2] == ',')) {
/* get the custom flags (if any) */
custom_flags = mu_flags_custom_from_str (cur + 3);
cur[0] = '\0'; /* strip the flags */
break;
}
}
}
newpath = get_new_path (new_mdir ? new_mdir : mdir,
mfile, newflags, custom_flags);
@ -859,7 +861,7 @@ msg_move (const char* src, const char *dst, GError **err)
gchar*
mu_maildir_move_message (const char* oldpath, const char* targetmdir,
MuFlags newflags, gboolean ignore_dups,
MuFlags newflags, gboolean ignore_dups, gboolean new_name,
GError **err)
{
char *newfullpath;
@ -869,7 +871,7 @@ mu_maildir_move_message (const char* oldpath, const char* targetmdir,
g_return_val_if_fail (oldpath, FALSE);
newfullpath = mu_maildir_get_new_path (oldpath, targetmdir,
newflags);
newflags, new_name);
if (!newfullpath) {
mu_util_g_set_error (err, MU_ERROR_FILE,
"failed to determine targetpath");