mirror of
https://github.com/imapsync/imapsync.git
synced 2025-08-04 16:01:29 +02:00
1.144
This commit is contained in:
parent
028e94e1f1
commit
f2bb3aabe8
8 changed files with 664 additions and 33 deletions
77
imapsync
77
imapsync
|
@ -6,7 +6,7 @@ imapsync - IMAP synchronization, copy or migration
|
|||
tool. Synchronize mailboxes between two imap servers. Good
|
||||
at IMAP migration.
|
||||
|
||||
$Revision: 1.143 $
|
||||
$Revision: 1.144 $
|
||||
|
||||
=head1 INSTALL
|
||||
|
||||
|
@ -41,7 +41,7 @@ $Revision: 1.143 $
|
|||
[--noauthmd5]
|
||||
[--folder <string> --folder <string> ...]
|
||||
[--include <regex>] [--exclude <regex>]
|
||||
[--prefix2 <string>]
|
||||
[--prefix2 <string>] [--prefix1 <string>]
|
||||
[--regextrans2 <regex> --regextrans2 <regex> ...]
|
||||
[--sep1 <char>]
|
||||
[--sep2 <char>]
|
||||
|
@ -306,7 +306,7 @@ Gilles LAMIRAL earn his living writing, installing,
|
|||
configuring and teaching free open and gratis
|
||||
softwares. Don't hesitate to pay him for that services.
|
||||
|
||||
$Id: imapsync,v 1.143 2005/11/27 20:36:12 gilles Exp $
|
||||
$Id: imapsync,v 1.144 2005/11/28 00:32:05 gilles Exp gilles $
|
||||
|
||||
=cut
|
||||
|
||||
|
@ -326,7 +326,9 @@ my(
|
|||
$rcs, $debug, $debugimap, $error,
|
||||
$host1, $host2, $port1, $port2,
|
||||
$user1, $user2, $password1, $password2, $passfile1, $passfile2,
|
||||
@folder, $include, $exclude, $prefix2, @regextrans2, @regexmess,
|
||||
@folder, $include, $exclude,
|
||||
$prefix1, $prefix2,
|
||||
@regextrans2, @regexmess,
|
||||
$sep1, $sep2,
|
||||
$syncinternaldates, $syncacls,
|
||||
$fastio1, $fastio2,
|
||||
|
@ -351,7 +353,7 @@ my(
|
|||
use vars qw ($opt_G); # missing code for this will be option.
|
||||
|
||||
|
||||
$rcs = ' $Id: imapsync,v 1.143 2005/11/27 20:36:12 gilles Exp $ ';
|
||||
$rcs = ' $Id: imapsync,v 1.144 2005/11/28 00:32:05 gilles Exp gilles $ ';
|
||||
$rcs =~ m/,v (\d+\.\d+)/;
|
||||
$VERSION = ($1) ? $1 : "UNKNOWN";
|
||||
|
||||
|
@ -388,8 +390,8 @@ $error=0;
|
|||
|
||||
my $banner = join("",
|
||||
'$RCSfile: imapsync,v $ ',
|
||||
'$Revision: 1.143 $ ',
|
||||
'$Date: 2005/11/27 20:36:12 $ ',
|
||||
'$Revision: 1.144 $ ',
|
||||
'$Date: 2005/11/28 00:32:05 $ ',
|
||||
"\n",
|
||||
"Mail::IMAPClient version used here is ",
|
||||
$VERSION_IMAPClient,"\n"
|
||||
|
@ -575,10 +577,39 @@ $debug and print "Getting separators\n";
|
|||
$f_sep = get_separator($from, $sep1, "--sep1");
|
||||
$t_sep = get_separator($to, $sep2, "--sep2");
|
||||
|
||||
my $f_namespace = $from->namespace();
|
||||
my $t_namespace = $to->namespace();
|
||||
$debug and print "From namespace:\n", Data::Dumper->Dump($f_namespace);
|
||||
$debug and print "To namespace:\n", Data::Dumper->Dump($t_namespace);
|
||||
#my $f_namespace = $from->namespace();
|
||||
#my $t_namespace = $to->namespace();
|
||||
#$debug and print "From namespace:\n", Data::Dumper->Dump([$f_namespace]);
|
||||
#$debug and print "To namespace:\n", Data::Dumper->Dump([$t_namespace]);
|
||||
|
||||
my($f_prefix,$t_prefix);
|
||||
$f_prefix = get_prefix($from, $prefix1, "--prefix1");
|
||||
$t_prefix = get_prefix($to, $prefix2, "--prefix2");
|
||||
|
||||
sub get_prefix {
|
||||
my($imap, $prefix_in, $prefix_opt) = @_;
|
||||
my($prefix_out);
|
||||
|
||||
$debug and print "Getting prefix namespace\n";
|
||||
if (defined($prefix_in)) {
|
||||
print "Using [$prefix_in] given by $prefix_opt\n";
|
||||
$prefix_out = $prefix_in;
|
||||
return($prefix_out);
|
||||
}
|
||||
$debug and print "Calling namespace capability\n";
|
||||
if ($imap->has_capability("namespace")) {
|
||||
my $r_namespace = $imap->namespace();
|
||||
$prefix_out = $r_namespace->[0][0][0];
|
||||
return($prefix_out);
|
||||
}else{
|
||||
print
|
||||
"No NAMESPACE capability in imap server ",
|
||||
$imap->Server(),"\n",
|
||||
"Give the prefix namespace with the $prefix_opt option\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub get_separator {
|
||||
my($imap, $sep_in, $sep_opt) = @_;
|
||||
|
@ -604,8 +635,8 @@ sub get_separator {
|
|||
}
|
||||
|
||||
|
||||
print "From separator : [$f_sep]\n";
|
||||
print "To separator : [$t_sep]\n";
|
||||
print "From separator and prefix : [$f_sep][$f_prefix]\n";
|
||||
print "To separator and prefix : [$t_sep][$t_prefix]\n";
|
||||
|
||||
|
||||
sub foldersizes {
|
||||
|
@ -705,10 +736,15 @@ FOLDER: foreach my $f_fold (@f_folders) {
|
|||
my $t_fold;
|
||||
print "From Folder [$f_fold]\n";
|
||||
|
||||
$t_fold = separator_invert($f_fold,$f_sep, $t_sep);
|
||||
|
||||
# Adding the prefix supplied by the --prefix2 option
|
||||
$t_fold = $prefix2 . $t_fold if ($prefix2);
|
||||
my $x_fold = $f_fold;
|
||||
# first we remove the prefix
|
||||
$x_fold =~ s/^$f_prefix//;
|
||||
$debug and print "removed source prefix : [$x_fold]\n";
|
||||
$t_fold = separator_invert($x_fold,$f_sep, $t_sep);
|
||||
$debug and print "inverted separators : [$t_fold]\n";
|
||||
# Adding the prefix supplied by namespace or the --prefix2 option
|
||||
$t_fold = $t_prefix . $t_fold unless($t_fold eq 'INBOX');
|
||||
$debug and print "added target prefix : [$t_fold]\n";
|
||||
|
||||
# Transforming the folder name by the --regextrans2 option(s)
|
||||
foreach my $regextrans2 (@regextrans2) {
|
||||
|
@ -1018,6 +1054,7 @@ sub get_options
|
|||
"folder=s" => \@folder,
|
||||
"include=s" => \$include,
|
||||
"exclude=s" => \$exclude,
|
||||
"prefix1=s" => \$prefix1,
|
||||
"prefix2=s" => \$prefix2,
|
||||
"regextrans2=s" => \@regextrans2,
|
||||
"regexmess=s" => \@regexmess,
|
||||
|
@ -1149,8 +1186,14 @@ Several options are mandatory.
|
|||
--exclude <regex> : skip folders matching this regular expression
|
||||
(only effective if neither --folder nor --subscribed
|
||||
is specified)
|
||||
--prefix1 <string> : remove prefix to all destination folders
|
||||
(usually INBOX. for cyrus imap servers)
|
||||
use --prefix1 if your source imap server does not
|
||||
have NAMESPACE capability.
|
||||
--prefix2 <string> : add prefix to all destination folders
|
||||
(usually INBOX. for cyrus imap servers)
|
||||
use --prefix2 if your target imap server does not
|
||||
have NAMESPACE capability.
|
||||
--regextrans2 <regex> : Apply the whole regex to each destination folders.
|
||||
--regextrans2 <regex> : and this one. etc.
|
||||
--regexmess <regex> : Apply the whole regex to each message before transfer.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue